

<!DOCTYPE html>
<!--[if IE 8]><html class="no-js lt-ie9" lang="zh-CN" > <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="zh-CN" > <!--<![endif]-->
<head>
  <meta charset="utf-8">
  
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  
  <title>WeIdentity RestService API 说明文档 &mdash; WeIdentity  文档</title>
  

  
  
  
  

  

  
  
    

  

  <link rel="stylesheet" href="../_static/css/theme.css" type="text/css" />
  <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
  <link rel="stylesheet" href="../_static/theme_overrides.css" type="text/css" />
  <link rel="stylesheet" href="../_static/index.css" type="text/css" />
    <link rel="index" title="索引" href="../genindex.html" />
    <link rel="search" title="搜索" href="../search.html" />
    <link rel="next" title="WeIdentity RestService 设计文档" href="weidentity-rest-design.html" />
    <link rel="prev" title="WeIdentity RestService 部署文档" href="weidentity-rest-deploy.html" /> 

  
  <script src="../_static/js/modernizr.min.js"></script>

</head>

<body class="wy-body-for-nav">

   
  <div class="wy-grid-for-nav">

    
    <nav data-toggle="wy-nav-shift" class="wy-nav-side">
      <div class="wy-side-scroll">
        <div class="wy-side-nav-search">
          

          
            <a href="../index.html" class="icon icon-home"> WeIdentity
          

          
          </a>

          
            
            
          

          
<div role="search">
  <form id="rtd-search-form" class="wy-form" action="../search.html" method="get">
    <input type="text" name="q" placeholder="Search docs" />
    <input type="hidden" name="check_keywords" value="yes" />
    <input type="hidden" name="area" value="default" />
  </form>
</div>

          
        </div>

        <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
          
            
            
              
            
            
              <p class="caption"><span class="caption-text">Contents:</span></p>
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="../README.html">什么是 WeIdentity？</a></li>
<li class="toctree-l1"><a class="reference internal" href="one-stop-experience.html">WeIdentity 一站式体验</a></li>
<li class="toctree-l1"><a class="reference internal" href="terminologies.html">术语</a></li>
<li class="toctree-l1"><a class="reference internal" href="use-cases.html">使用场景</a></li>
<li class="toctree-l1"><a class="reference internal" href="weidentity-spec.html">WeIdentity 规范</a></li>
<li class="toctree-l1"><a class="reference internal" href="weidentity-installation.html">WeIdentity Java SDK 安装部署</a></li>
<li class="toctree-l1"><a class="reference external" href="https://weidentity.readthedocs.io/projects/javasdk/zh_CN/latest/">WeIdentity Java SDK 文档</a></li>
<li class="toctree-l1"><a class="reference internal" href="weidentity-sample.html">WeIdentity Sample 开发样例</a></li>
<li class="toctree-l1"><a class="reference internal" href="miscellaneous.html">杂项</a></li>
<li class="toctree-l1"><a class="reference internal" href="faq.html">FAQ</a></li>
<li class="toctree-l1 current"><a class="reference internal" href="weidentity-rest.html">WeIdentity RestService</a><ul class="current">
<li class="toctree-l2"><a class="reference internal" href="weidentity-rest.html#restservice">部署RestService</a></li>
<li class="toctree-l2 current"><a class="reference internal" href="weidentity-rest.html#id2">使用RestService</a><ul class="current">
<li class="toctree-l3 current"><a class="current reference internal" href="#">WeIdentity RestService API 说明文档</a><ul>
<li class="toctree-l4"><a class="reference internal" href="#restservice-api">基于私钥托管模式的RestService API</a></li>
<li class="toctree-l4"><a class="reference internal" href="#id6">基于轻客户端模式的RestService API</a></li>
<li class="toctree-l4"><a class="reference internal" href="#weidentity-endpoint-service-api">WeIdentity Endpoint Service API</a></li>
</ul>
</li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="weidentity-rest.html#id3">深入了解RestService</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="weidentity-endpoint.html">WeIdentity Endpoint Service</a></li>
<li class="toctree-l1"><a class="reference internal" href="weidentity-contract-design.html">WeIdentity 智能合约设计与实现</a></li>
</ul>

            
          
        </div>
      </div>
    </nav>

    <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">

      
      <nav class="wy-nav-top" aria-label="top navigation">
        
          <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
          <a href="../index.html">WeIdentity</a>
        
      </nav>


      <div class="wy-nav-content">
        
        <div class="rst-content">
        
          















<div role="navigation" aria-label="breadcrumbs navigation">

  <ul class="wy-breadcrumbs">
    
      <li><a href="../index.html">Docs</a> &raquo;</li>
        
          <li><a href="weidentity-rest.html">WeIdentity RestService</a> &raquo;</li>
        
      <li>WeIdentity RestService API 说明文档</li>
    
    
      <li class="wy-breadcrumbs-aside">
        
            
            <a href="../_sources/docs/weidentity-rest-api.rst.txt" rel="nofollow"> View page source</a>
          
        
      </li>
    
  </ul>

  
  <hr/>
</div>
          <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
           <div itemprop="articleBody">
            
  <div class="section" id="weidentity-restservice-api">
<span id="weidentity-rest-api"></span><h1>WeIdentity RestService API 说明文档<a class="headerlink" href="#weidentity-restservice-api" title="永久链接至标题">¶</a></h1>
<div class="section" id="restservice-api">
<h2>基于私钥托管模式的RestService API<a class="headerlink" href="#restservice-api" title="永久链接至标题">¶</a></h2>
<div class="section" id="id1">
<h3>1. 总体介绍<a class="headerlink" href="#id1" title="永久链接至标题">¶</a></h3>
<p>每个API的入参都是满足以下格式的json字符串：</p>
<div class="highlight-java notranslate"><div class="highlight"><pre><span></span>{
    &quot;functionArg&quot;: 随调用SDK方法而变的入参json字符串 {
        ...
    },
    &quot;transactionArg&quot;: 交易参数json字符串 {
        &quot;invokerWeId&quot;: 用于索引私钥的WeIdentity DID，服务器端会凭此找到所托管的私钥（非必须）
    }
    &quot;functionName&quot;: 调用SDK方法名
    &quot;v&quot;: API版本号
}
</pre></div>
</div>
<p>参数说明：</p>
<ul class="simple">
<li><p>functionArg是随不同的SDK调用方法而变的，具体的参数可以查看SDK接口文档；后文会为每个所提及的接口给出对应的链接</p></li>
<li><dl class="simple">
<dt>transactionArg仅包括一个变量invokerWeId，由传入方决定使用在服务器端托管的具体哪个WeIdentity DID所对应的私钥</dt><dd><ul>
<li><p>非必需，只有在那些需要使用不同身份进行写交易签名的方法（如CreateAuthorityIssuer等）才会需要；后文中详细说明</p></li>
</ul>
</dd>
</dl>
</li>
<li><p>functionName是调用的SDK方法名，用于决定具体调用WeIdentity Java SDK的什么功能</p></li>
<li><p>v是调用的API方法版本</p></li>
</ul>
<p>每个API的接口返回都是满足以下格式的json字符串：</p>
<div class="highlight-java notranslate"><div class="highlight"><pre><span></span>{
    &quot;respBody&quot;: 随调用SDK方法而变的输出值json字符串 {
    }
    &quot;ErrorCode&quot;: 错误码
    &quot;ErrorMessage&quot;: 错误信息，成功时为&quot;success&quot;
}
</pre></div>
</div>
<p>其中具体的输出值result亦是随不同的SDK调用方法而变的。</p>
<p>在后文中，我们将会逐一说明目前所提供的功能及其使用方式。</p>
</div>
<div class="section" id="weidentity-did">
<h3>2. 创建WeIdentity DID（无参创建方式）<a class="headerlink" href="#weidentity-did" title="永久链接至标题">¶</a></h3>
<p>调用接口：</p>
<table class="colwidths-given docutils align-default">
<colgroup>
<col style="width: 38%" />
<col style="width: 63%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>标题</p></th>
<th class="head"><p>描述</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>接口名</p></td>
<td><p>weid/api/invoke</p></td>
</tr>
<tr class="row-odd"><td><p>Method</p></td>
<td><p>POST</p></td>
</tr>
<tr class="row-even"><td><p>Content-Type</p></td>
<td><p>application/json</p></td>
</tr>
</tbody>
</table>
<p>接口入参：</p>
<table class="colwidths-given docutils align-default">
<colgroup>
<col style="width: 27%" />
<col style="width: 55%" />
<col style="width: 18%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>Key</p></th>
<th class="head"><p>Value</p></th>
<th class="head"><p>Required</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>functionName</p></td>
<td><p>createWeId</p></td>
<td><p>Y</p></td>
</tr>
<tr class="row-odd"><td><p>functionArg</p></td>
<td></td>
<td><p>Y</p></td>
</tr>
<tr class="row-even"><td><p>transactionArg</p></td>
<td></td>
<td><p>Y</p></td>
</tr>
<tr class="row-odd"><td><p>v</p></td>
<td><p>版本号</p></td>
<td><p>Y</p></td>
</tr>
</tbody>
</table>
<div class="admonition note">
<p class="admonition-title">注解</p>
<p>基于托管模式的RestService不允许通过传入公钥参数的方式创建WeID。这是因为，这样生成的WeID私钥不存在于RestService本地，因此无法在后续过程中被调用。如果您需要通过传入公钥方式创建WeID，请使用基于轻客户端方式的接口创建。</p>
</div>
<p>接口入参示例：</p>
<div class="highlight-java notranslate"><div class="highlight"><pre><span></span><span class="o">{</span>
    <span class="s">&quot;functionArg&quot;</span><span class="o">:</span> <span class="o">{</span>
    <span class="o">},</span>
    <span class="s">&quot;transactionArg&quot;</span><span class="o">:</span> <span class="o">{</span>
    <span class="o">},</span>
    <span class="s">&quot;functionName&quot;</span><span class="o">:</span> <span class="s">&quot;createWeId&quot;</span><span class="o">,</span>
    <span class="s">&quot;v&quot;</span><span class="o">:</span> <span class="s">&quot;1.0.0&quot;</span>
<span class="o">}</span>
</pre></div>
</div>
<p>接口返回: application/json</p>
<table class="colwidths-given docutils align-default">
<colgroup>
<col style="width: 38%" />
<col style="width: 63%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>Key</p></th>
<th class="head"><p>Value</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>ErrorCode</p></td>
<td><p>错误码，0表示成功</p></td>
</tr>
<tr class="row-odd"><td><p>ErrorMessage</p></td>
<td><p>错误信息</p></td>
</tr>
<tr class="row-even"><td><p>respBody</p></td>
<td><p>WeIdentity DID</p></td>
</tr>
</tbody>
</table>
<p>返回示例：</p>
<div class="highlight-java notranslate"><div class="highlight"><pre><span></span><span class="o">{</span>
    <span class="s">&quot;ErrorCode&quot;</span><span class="o">:</span> <span class="mi">0</span><span class="o">,</span>
    <span class="s">&quot;ErrorMessage&quot;</span><span class="o">:</span> <span class="s">&quot;success&quot;</span><span class="o">,</span>
    <span class="s">&quot;respBody&quot;</span><span class="o">:</span> <span class="s">&quot;did:weid:0xfd28ad212a2de77fee518b4914b8579a40c601fa&quot;</span>
<span class="o">}</span>
</pre></div>
</div>
</div>
<div class="section" id="weidentity-did-document">
<h3>3. 获取WeIdentity DID Document<a class="headerlink" href="#weidentity-did-document" title="永久链接至标题">¶</a></h3>
<p>调用接口：</p>
<table class="colwidths-given docutils align-default">
<colgroup>
<col style="width: 38%" />
<col style="width: 63%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>标题</p></th>
<th class="head"><p>描述</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>接口名</p></td>
<td><p>weid/api/invoke</p></td>
</tr>
<tr class="row-odd"><td><p>Method</p></td>
<td><p>POST</p></td>
</tr>
<tr class="row-even"><td><p>Content-Type</p></td>
<td><p>application/json</p></td>
</tr>
</tbody>
</table>
<p>接口入参：</p>
<table class="colwidths-given docutils align-default">
<colgroup>
<col style="width: 27%" />
<col style="width: 55%" />
<col style="width: 18%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>Key</p></th>
<th class="head"><p>Value</p></th>
<th class="head"><p>Required</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>functionName</p></td>
<td><p>getWeIdDocument</p></td>
<td><p>Y</p></td>
</tr>
<tr class="row-odd"><td><p>functionArg</p></td>
<td></td>
<td><p>Y</p></td>
</tr>
<tr class="row-even"><td><p>functionArg.weId</p></td>
<td><p>WeIdentity DID，与SDK直接调用的方式入参要求一致，下同</p></td>
<td><p>Y</p></td>
</tr>
<tr class="row-odd"><td><p>transactionArg</p></td>
<td></td>
<td><p>N，传空</p></td>
</tr>
<tr class="row-even"><td><p>v</p></td>
<td><p>版本号</p></td>
<td><p>Y</p></td>
</tr>
</tbody>
</table>
<p>接口入参示例：</p>
<div class="highlight-java notranslate"><div class="highlight"><pre><span></span><span class="o">{</span>
    <span class="s">&quot;functionArg&quot;</span><span class="o">:</span> <span class="o">{</span>
        <span class="s">&quot;weId&quot;</span><span class="o">:</span> <span class="s">&quot;did:weid:0xfd28ad212a2de77fee518b4914b8579a40c601fa&quot;</span>
    <span class="o">},</span>
    <span class="s">&quot;transactionArg&quot;</span><span class="o">:</span> <span class="o">{</span>
    <span class="o">},</span>
    <span class="s">&quot;functionName&quot;</span><span class="o">:</span> <span class="s">&quot;getWeIdDocument&quot;</span><span class="o">,</span>
    <span class="s">&quot;v&quot;</span><span class="o">:</span> <span class="s">&quot;1.0.0&quot;</span>
<span class="o">}</span>
</pre></div>
</div>
<p>接口返回: application/json</p>
<table class="colwidths-given docutils align-default">
<colgroup>
<col style="width: 38%" />
<col style="width: 63%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>Key</p></th>
<th class="head"><p>Value</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>ErrorCode</p></td>
<td><p>错误码，0表示成功</p></td>
</tr>
<tr class="row-odd"><td><p>ErrorMessage</p></td>
<td><p>错误信息</p></td>
</tr>
<tr class="row-even"><td><p>respBody</p></td>
<td><p>WeIdentity DID Document</p></td>
</tr>
</tbody>
</table>
<p>返回示例：</p>
<div class="highlight-java notranslate"><div class="highlight"><pre><span></span><span class="o">{</span>
    <span class="s">&quot;respBody&quot;</span><span class="o">:</span> <span class="o">{</span>
        <span class="s">&quot;@context&quot;</span> <span class="o">:</span> <span class="s">&quot;https://w3id.org/did/v1&quot;</span><span class="o">,</span>
        <span class="s">&quot;id&quot;</span> <span class="o">:</span> <span class="s">&quot;did:weid:0xfd28ad212a2de77fee518b4914b8579a40c601fa&quot;</span><span class="o">,</span>
        <span class="s">&quot;created&quot;</span> <span class="o">:</span> <span class="mi">1553224394993</span><span class="o">,</span>
        <span class="s">&quot;updated&quot;</span> <span class="o">:</span> <span class="mi">1553224394993</span><span class="o">,</span>
        <span class="s">&quot;publicKey&quot;</span> <span class="o">:</span> <span class="o">[</span> <span class="o">],</span>
        <span class="s">&quot;authentication&quot;</span> <span class="o">:</span> <span class="o">[</span> <span class="o">],</span>
        <span class="s">&quot;service&quot;</span> <span class="o">:</span> <span class="o">[</span> <span class="o">]</span>
    <span class="o">},</span>
    <span class="s">&quot;ErrorCode&quot;</span><span class="o">:</span> <span class="mi">0</span><span class="o">,</span>
    <span class="s">&quot;ErrorMessage&quot;</span><span class="o">:</span> <span class="s">&quot;success&quot;</span>
<span class="o">}</span>
</pre></div>
</div>
</div>
<div class="section" id="authorityissuer">
<h3>4. 创建AuthorityIssuer<a class="headerlink" href="#authorityissuer" title="永久链接至标题">¶</a></h3>
<p>调用接口：</p>
<table class="colwidths-given docutils align-default">
<colgroup>
<col style="width: 38%" />
<col style="width: 63%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>标题</p></th>
<th class="head"><p>描述</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>接口名</p></td>
<td><p>weid/api/invoke</p></td>
</tr>
<tr class="row-odd"><td><p>Method</p></td>
<td><p>POST</p></td>
</tr>
<tr class="row-even"><td><p>Content-Type</p></td>
<td><p>application/json</p></td>
</tr>
</tbody>
</table>
<p>接口入参：</p>
<table class="colwidths-given docutils align-default">
<colgroup>
<col style="width: 27%" />
<col style="width: 55%" />
<col style="width: 18%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>Key</p></th>
<th class="head"><p>Value</p></th>
<th class="head"><p>Required</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>functionName</p></td>
<td><p>registerAuthorityIssuer</p></td>
<td><p>Y</p></td>
</tr>
<tr class="row-odd"><td><p>functionArg</p></td>
<td></td>
<td><p>Y</p></td>
</tr>
<tr class="row-even"><td><p>functionArg.weId</p></td>
<td><p>WeIdentity DID，与SDK直接调用的方式入参一致，下同</p></td>
<td><p>Y</p></td>
</tr>
<tr class="row-odd"><td><p>functionArg.name</p></td>
<td><p>机构名</p></td>
<td><p>Y</p></td>
</tr>
<tr class="row-even"><td><p>transactionArg</p></td>
<td></td>
<td><p>Y</p></td>
</tr>
<tr class="row-odd"><td><p>transactionArg.invokerWeId</p></td>
<td><p>用于索引私钥的WeIdentity DID，服务器端会凭此找到所托管的私钥。注意：如果在这里填入了预先定义在application.properties里的暗语，则可确保有足够的权限。</p></td>
<td><p>Y</p></td>
</tr>
<tr class="row-even"><td><p>v</p></td>
<td><p>版本号</p></td>
<td><p>Y</p></td>
</tr>
</tbody>
</table>
<p>接口调用示例：</p>
<div class="highlight-java notranslate"><div class="highlight"><pre><span></span><span class="o">{</span>
    <span class="s">&quot;functionArg&quot;</span><span class="o">:</span> <span class="o">{</span>
        <span class="s">&quot;weid&quot;</span><span class="o">:</span> <span class="s">&quot;did:weid:0x1Ae5b88d37327830307ab8da0ec5D8E8692A35D3&quot;</span><span class="o">,</span>
        <span class="s">&quot;name&quot;</span><span class="o">:</span> <span class="s">&quot;Sample College&quot;</span>
    <span class="o">},</span>
    <span class="s">&quot;transactionArg&quot;</span><span class="o">:</span> <span class="o">{</span>
        <span class="s">&quot;invokerWeId&quot;</span><span class="o">:</span> <span class="s">&quot;did:weid:0xfd28ad212a2de77fee518b4914b8579a40c601fa&quot;</span>
    <span class="o">},</span>
    <span class="s">&quot;functionName&quot;</span><span class="o">:</span> <span class="s">&quot;registerAuthorityIssuer&quot;</span><span class="o">,</span>
    <span class="s">&quot;v&quot;</span><span class="o">:</span> <span class="s">&quot;1.0.0&quot;</span>
<span class="o">}</span>
</pre></div>
</div>
<p>接口返回: application/json</p>
<table class="colwidths-given docutils align-default">
<colgroup>
<col style="width: 38%" />
<col style="width: 63%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>Key</p></th>
<th class="head"><p>Value</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>ErrorCode</p></td>
<td><p>错误码，0表示成功</p></td>
</tr>
<tr class="row-odd"><td><p>ErrorMessage</p></td>
<td><p>错误信息</p></td>
</tr>
<tr class="row-even"><td><p>respBody</p></td>
<td><p>True/False</p></td>
</tr>
</tbody>
</table>
<p>返回示例：</p>
<div class="highlight-java notranslate"><div class="highlight"><pre><span></span><span class="o">{</span>
    <span class="s">&quot;ErrorCode&quot;</span><span class="o">:</span> <span class="mi">0</span><span class="o">,</span>
    <span class="s">&quot;ErrorMessage&quot;</span><span class="o">:</span> <span class="s">&quot;success&quot;</span><span class="o">,</span>
    <span class="s">&quot;respBody&quot;</span><span class="o">:</span> <span class="n">True</span>
<span class="o">}</span>
</pre></div>
</div>
</div>
<div class="section" id="id2">
<h3>5. 查询AuthorityIssuer<a class="headerlink" href="#id2" title="永久链接至标题">¶</a></h3>
<p>调用接口：</p>
<table class="colwidths-given docutils align-default">
<colgroup>
<col style="width: 38%" />
<col style="width: 63%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>标题</p></th>
<th class="head"><p>描述</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>接口名</p></td>
<td><p>weid/api/invoke</p></td>
</tr>
<tr class="row-odd"><td><p>Method</p></td>
<td><p>POST</p></td>
</tr>
<tr class="row-even"><td><p>Content-Type</p></td>
<td><p>application/json</p></td>
</tr>
</tbody>
</table>
<p>接口入参：</p>
<table class="colwidths-given docutils align-default">
<colgroup>
<col style="width: 27%" />
<col style="width: 55%" />
<col style="width: 18%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>Key</p></th>
<th class="head"><p>Value</p></th>
<th class="head"><p>Required</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>functionName</p></td>
<td><p>queryAuthorityIssuer</p></td>
<td><p>Y</p></td>
</tr>
<tr class="row-odd"><td><p>functionArg</p></td>
<td></td>
<td><p>Y</p></td>
</tr>
<tr class="row-even"><td><p>functionArg.weId</p></td>
<td><p>WeIdentity DID，与SDK直接调用的方式入参一致，下同</p></td>
<td><p>Y</p></td>
</tr>
<tr class="row-odd"><td><p>transactionArg</p></td>
<td></td>
<td><p>N，传空</p></td>
</tr>
<tr class="row-even"><td><p>v</p></td>
<td><p>版本号</p></td>
<td><p>Y</p></td>
</tr>
</tbody>
</table>
<p>接口入参示例：</p>
<div class="highlight-java notranslate"><div class="highlight"><pre><span></span><span class="o">{</span>
    <span class="s">&quot;functionArg&quot;</span><span class="o">:</span> <span class="o">{</span>
        <span class="s">&quot;weId&quot;</span><span class="o">:</span> <span class="s">&quot;did:weid:0x1ae5b88d37327830307ab8da0ec5d8e8692a35d3&quot;</span>
    <span class="o">},</span>
    <span class="s">&quot;transactionArg&quot;</span><span class="o">:</span> <span class="o">{</span>
    <span class="o">},</span>
    <span class="s">&quot;functionName&quot;</span><span class="o">:</span> <span class="s">&quot;queryAuthorityIssuer&quot;</span><span class="o">,</span>
    <span class="s">&quot;v&quot;</span><span class="o">:</span> <span class="s">&quot;1.0.0&quot;</span>
<span class="o">}</span>
</pre></div>
</div>
<p>接口返回: application/json</p>
<table class="colwidths-given docutils align-default">
<colgroup>
<col style="width: 38%" />
<col style="width: 63%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>Key</p></th>
<th class="head"><p>Value</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>ErrorCode</p></td>
<td><p>错误码，0表示成功</p></td>
</tr>
<tr class="row-odd"><td><p>ErrorMessage</p></td>
<td><p>错误信息</p></td>
</tr>
<tr class="row-even"><td><p>respBody</p></td>
<td><p>完整的Authority Issuer信息</p></td>
</tr>
</tbody>
</table>
<div class="highlight-java notranslate"><div class="highlight"><pre><span></span><span class="o">{</span>
    <span class="s">&quot;respBody&quot;</span><span class="o">:</span> <span class="o">{</span>
        <span class="s">&quot;accValue&quot;</span><span class="o">:</span> <span class="o">,</span>
        <span class="s">&quot;created&quot;</span><span class="o">:</span> <span class="mi">16845611984115</span><span class="o">,</span>
        <span class="s">&quot;name&quot;</span><span class="o">:</span> <span class="s">&quot;Sample College&quot;</span><span class="o">,</span>
        <span class="s">&quot;weid&quot;</span><span class="o">:</span> <span class="s">&quot;did:weid:0x1ae5b88d37327830307ab8da0ec5d8e8692a35d3&quot;</span>
    <span class="o">}</span>
    <span class="s">&quot;ErrorCode&quot;</span><span class="o">:</span> <span class="mi">0</span>
    <span class="s">&quot;ErrorMessage&quot;</span><span class="o">:</span> <span class="s">&quot;success&quot;</span>
<span class="o">}</span>
</pre></div>
</div>
</div>
<div class="section" id="cpt">
<h3>6. 创建CPT<a class="headerlink" href="#cpt" title="永久链接至标题">¶</a></h3>
<p>调用接口：</p>
<table class="colwidths-given docutils align-default">
<colgroup>
<col style="width: 38%" />
<col style="width: 63%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>标题</p></th>
<th class="head"><p>描述</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>接口名</p></td>
<td><p>weid/api/invoke</p></td>
</tr>
<tr class="row-odd"><td><p>Method</p></td>
<td><p>POST</p></td>
</tr>
<tr class="row-even"><td><p>Content-Type</p></td>
<td><p>application/json</p></td>
</tr>
</tbody>
</table>
<p>接口入参:</p>
<table class="colwidths-given docutils align-default">
<colgroup>
<col style="width: 27%" />
<col style="width: 55%" />
<col style="width: 18%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>Key</p></th>
<th class="head"><p>Value</p></th>
<th class="head"><p>Required</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>functionName</p></td>
<td><p>registerCpt</p></td>
<td><p>Y</p></td>
</tr>
<tr class="row-odd"><td><p>functionArg</p></td>
<td></td>
<td><p>Y</p></td>
</tr>
<tr class="row-even"><td><p>functionArg.cptJsonSchema</p></td>
<td><p>CPT Json Schema，与SDK直接调用的方式入参一致，下同</p></td>
<td><p>Y</p></td>
</tr>
<tr class="row-odd"><td><p>functionArg.weId</p></td>
<td><p>CPT创建者</p></td>
<td><p>Y</p></td>
</tr>
<tr class="row-even"><td><p>transactionArg</p></td>
<td></td>
<td><p>Y</p></td>
</tr>
<tr class="row-odd"><td><p>transactionArg.invokerWeId</p></td>
<td><p>用于索引私钥的WeIdentity DID，服务器端会凭此找到所托管的私钥</p></td>
<td><p>Y</p></td>
</tr>
<tr class="row-even"><td><p>v</p></td>
<td><p>版本号</p></td>
<td><p>Y</p></td>
</tr>
</tbody>
</table>
<div class="highlight-text notranslate"><div class="highlight"><pre><span></span>CPT Json Schema是什么？应该满足什么格式？

答：Json Schema是一种用来定义Json字符串格式的Json字符串，它定义了CPT应包括的字段、属性及规则。
WeIdentity可以接受 http://json-schema.org/draft-04/schema# 所定义第四版及之前版本作为入参。
</pre></div>
</div>
<p>接口入参示例：</p>
<div class="highlight-java notranslate"><div class="highlight"><pre><span></span>{
  &quot;functionArg&quot;: {
      &quot;weId&quot;: &quot;did:weid:0x1ae5b88d37327830307ab8da0ec5d8e8692a35d3&quot;,
      &quot;cptJsonSchema&quot;:{
          &quot;title&quot;: &quot;cpt&quot;,
          &quot;description&quot;: &quot;this is cpt&quot;,
          &quot;properties&quot;: {
              &quot;name&quot;: {
                  &quot;type&quot;: &quot;string&quot;,
                  &quot;description&quot;: &quot;the name of certificate owner&quot;
              },
              &quot;gender&quot;: {
                  &quot;enum&quot;: [
                      &quot;F&quot;,
                      &quot;M&quot;
                  ],
                  &quot;type&quot;: &quot;string&quot;,
                  &quot;description&quot;: &quot;the gender of certificate owner&quot;
              },
              &quot;age&quot;: {
                  &quot;type&quot;: &quot;number&quot;,
                  &quot;description&quot;: &quot;the age of certificate owner&quot;
              }
          },
          &quot;required&quot;: [
              &quot;name&quot;,
              &quot;age&quot;
          ]
      }
  },
  &quot;transactionArg&quot;: {
      &quot;invokerWeId&quot;: &quot;did:weid:0x1ae5b88d37327830307ab8da0ec5d8e8692a35d3&quot;
  }，
  &quot;functionName&quot;: &quot;registerCpt&quot;，
  &quot;v&quot;: &quot;1.0.0&quot;
}
</pre></div>
</div>
<p>接口返回: application/json</p>
<table class="colwidths-given docutils align-default">
<colgroup>
<col style="width: 38%" />
<col style="width: 63%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>Key</p></th>
<th class="head"><p>Value</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>ErrorCode</p></td>
<td><p>错误码，0表示成功</p></td>
</tr>
<tr class="row-odd"><td><p>ErrorMessage</p></td>
<td><p>错误信息</p></td>
</tr>
<tr class="row-even"><td><p>respBody</p></td>
<td><p>cptBaseInfo</p></td>
</tr>
</tbody>
</table>
<p>返回示例：</p>
<div class="highlight-java notranslate"><div class="highlight"><pre><span></span><span class="o">{</span>
    <span class="s">&quot;respBody&quot;</span><span class="o">:</span> <span class="o">{</span>
        <span class="s">&quot;cptId&quot;</span><span class="o">:</span> <span class="mi">2000001</span><span class="o">,</span>
        <span class="s">&quot;cptVersion&quot;</span><span class="o">:</span> <span class="mi">1</span>
    <span class="o">},</span>
    <span class="s">&quot;ErrorCode&quot;</span><span class="o">:</span> <span class="mi">0</span><span class="o">,</span>
    <span class="s">&quot;ErrorMessage&quot;</span><span class="o">:</span> <span class="s">&quot;success&quot;</span>
<span class="o">}</span>
</pre></div>
</div>
</div>
<div class="section" id="id3">
<h3>7. 查询CPT<a class="headerlink" href="#id3" title="永久链接至标题">¶</a></h3>
<p>调用接口：</p>
<table class="colwidths-given docutils align-default">
<colgroup>
<col style="width: 38%" />
<col style="width: 63%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>标题</p></th>
<th class="head"><p>描述</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>接口名</p></td>
<td><p>weid/api/invoke</p></td>
</tr>
<tr class="row-odd"><td><p>Method</p></td>
<td><p>POST</p></td>
</tr>
<tr class="row-even"><td><p>Content-Type</p></td>
<td><p>application/json</p></td>
</tr>
</tbody>
</table>
<p>接口入参：</p>
<table class="colwidths-given docutils align-default">
<colgroup>
<col style="width: 27%" />
<col style="width: 55%" />
<col style="width: 18%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>Key</p></th>
<th class="head"><p>Value</p></th>
<th class="head"><p>Required</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>functionName</p></td>
<td><p>queryCpt</p></td>
<td><p>Y</p></td>
</tr>
<tr class="row-odd"><td><p>functionArg</p></td>
<td></td>
<td><p>Y</p></td>
</tr>
<tr class="row-even"><td><p>functionArg.cptId</p></td>
<td><p>CPT ID，与SDK直接调用的方式入参一致。</p></td>
<td><p>Y</p></td>
</tr>
<tr class="row-odd"><td><p>transactionArg</p></td>
<td></td>
<td><p>N，传空</p></td>
</tr>
<tr class="row-even"><td><p>v</p></td>
<td><p>版本号</p></td>
<td><p>Y</p></td>
</tr>
</tbody>
</table>
<p>接口入参示例：</p>
<div class="highlight-java notranslate"><div class="highlight"><pre><span></span><span class="o">{</span>
    <span class="s">&quot;functionArg&quot;</span><span class="o">:</span> <span class="o">{</span>
        <span class="s">&quot;cptId&quot;</span><span class="o">:</span> <span class="mi">10</span><span class="o">,</span>
    <span class="o">},</span>
    <span class="s">&quot;transactionArg&quot;</span><span class="o">:</span> <span class="o">{</span>
    <span class="o">},</span>
    <span class="s">&quot;functionName&quot;</span><span class="o">:</span> <span class="s">&quot;queryCpt&quot;</span><span class="o">,</span>
    <span class="s">&quot;v&quot;</span><span class="o">:</span> <span class="s">&quot;1.0.0&quot;</span>
<span class="o">}</span>
</pre></div>
</div>
<p>接口返回: application/json</p>
<table class="colwidths-given docutils align-default">
<colgroup>
<col style="width: 38%" />
<col style="width: 63%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>Key</p></th>
<th class="head"><p>Value</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>ErrorCode</p></td>
<td><p>错误码，0表示成功</p></td>
</tr>
<tr class="row-odd"><td><p>ErrorMessage</p></td>
<td><p>错误信息</p></td>
</tr>
<tr class="row-even"><td><p>respBody</p></td>
<td><p>完整的CPT信息</p></td>
</tr>
</tbody>
</table>
<p>接口返回示例：</p>
<div class="highlight-java notranslate"><div class="highlight"><pre><span></span><span class="o">{</span>
    <span class="s">&quot;respBody&quot;</span><span class="o">:</span> <span class="o">{</span>
        <span class="s">&quot;cptBaseInfo&quot;</span> <span class="o">:</span> <span class="o">{</span>
            <span class="s">&quot;cptId&quot;</span> <span class="o">:</span> <span class="mi">10</span><span class="o">,</span>
            <span class="s">&quot;cptVersion&quot;</span> <span class="o">:</span> <span class="mi">1</span>
        <span class="o">},</span>
        <span class="s">&quot;cptId&quot;</span> <span class="o">:</span> <span class="mi">10</span><span class="o">,</span>
        <span class="s">&quot;cptJsonSchema&quot;</span> <span class="o">:</span> <span class="o">{</span>
            <span class="s">&quot;$schema&quot;</span> <span class="o">:</span> <span class="s">&quot;http://json-schema.org/draft-04/schema#&quot;</span><span class="o">,</span>
            <span class="s">&quot;title&quot;</span> <span class="o">:</span> <span class="s">&quot;a CPT schema&quot;</span><span class="o">,</span>
            <span class="s">&quot;type&quot;</span> <span class="o">:</span> <span class="s">&quot;object&quot;</span>
        <span class="o">},</span>
        <span class="s">&quot;cptPublisher&quot;</span> <span class="o">:</span> <span class="s">&quot;did:weid:0x104a58c272e8ebde0c29083552ebe78581322908&quot;</span><span class="o">,</span>
        <span class="s">&quot;cptSignature&quot;</span> <span class="o">:</span> <span class="s">&quot;HJPbDmoi39xgZBGi/aj1zB6VQL5QLyt4qTV6GOvQwzfgUJEZTazKZXe1dRg5aCt8Q44GwNF2k+l1rfhpY1hc/ls=&quot;</span><span class="o">,</span>
        <span class="s">&quot;cptVersion&quot;</span> <span class="o">:</span> <span class="mi">1</span><span class="o">,</span>
        <span class="s">&quot;created&quot;</span> <span class="o">:</span> <span class="mi">1553503354555</span><span class="o">,</span>
        <span class="s">&quot;metaData&quot;</span> <span class="o">:</span> <span class="o">{</span>
            <span class="s">&quot;cptPublisher&quot;</span> <span class="o">:</span> <span class="s">&quot;did:weid:0x104a58c272e8ebde0c29083552ebe78581322908&quot;</span><span class="o">,</span>
            <span class="s">&quot;cptSignature&quot;</span> <span class="o">:</span> <span class="s">&quot;HJPbDmoi39xgZBGi/aj1zB6VQL5QLyt4qTV6GOvQwzfgUJEZTazKZXe1dRg5aCt8Q44GwNF2k+l1rfhpY1hc/ls=&quot;</span><span class="o">,</span>
            <span class="s">&quot;created&quot;</span> <span class="o">:</span> <span class="mi">1553503354555</span><span class="o">,</span>
            <span class="s">&quot;updated&quot;</span> <span class="o">:</span> <span class="mi">0</span>
        <span class="o">},</span>
        <span class="s">&quot;updated&quot;</span> <span class="o">:</span> <span class="mi">0</span>
    <span class="o">},</span>
    <span class="s">&quot;ErrorCode&quot;</span><span class="o">:</span> <span class="mi">0</span><span class="o">,</span>
    <span class="s">&quot;ErrorMessage&quot;</span><span class="o">:</span> <span class="s">&quot;success&quot;</span>
<span class="o">}</span>
</pre></div>
</div>
</div>
<div class="section" id="credential">
<h3>8. 创建Credential<a class="headerlink" href="#credential" title="永久链接至标题">¶</a></h3>
<p>调用接口：</p>
<table class="colwidths-given docutils align-default">
<colgroup>
<col style="width: 38%" />
<col style="width: 63%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>标题</p></th>
<th class="head"><p>描述</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>接口名</p></td>
<td><p>weid/api/invoke</p></td>
</tr>
<tr class="row-odd"><td><p>Method</p></td>
<td><p>POST</p></td>
</tr>
<tr class="row-even"><td><p>Content-Type</p></td>
<td><p>application/json</p></td>
</tr>
</tbody>
</table>
<p>接口入参：</p>
<table class="colwidths-given docutils align-default">
<colgroup>
<col style="width: 27%" />
<col style="width: 55%" />
<col style="width: 18%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>Key</p></th>
<th class="head"><p>Value</p></th>
<th class="head"><p>Required</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>functionName</p></td>
<td><p>createCredential</p></td>
<td><p>Y</p></td>
</tr>
<tr class="row-odd"><td><p>functionArg</p></td>
<td></td>
<td><p>Y</p></td>
</tr>
<tr class="row-even"><td><p>functionArg.claim</p></td>
<td><p>claim Json结构体，与SDK直接调用的方式入参一致，下同</p></td>
<td><p>Y</p></td>
</tr>
<tr class="row-odd"><td><p>functionArg.cptId</p></td>
<td><p>CPT ID</p></td>
<td><p>Y</p></td>
</tr>
<tr class="row-even"><td><p>functionArg.issuer</p></td>
<td><p>issuer WeIdentity DID</p></td>
<td><p>Y</p></td>
</tr>
<tr class="row-odd"><td><p>functionArg.expirationDate</p></td>
<td><p>过期时间（使用UTC格式）</p></td>
<td><p>Y</p></td>
</tr>
<tr class="row-even"><td><p>transactionArg</p></td>
<td></td>
<td><p>Y</p></td>
</tr>
<tr class="row-odd"><td><p>transactionArg.invokerWeId</p></td>
<td><p>用于索引私钥的WeIdentity DID，服务器端会凭此找到所托管的私钥</p></td>
<td><p>Y</p></td>
</tr>
<tr class="row-even"><td><p>v</p></td>
<td><p>版本号</p></td>
<td><p>Y</p></td>
</tr>
</tbody>
</table>
<p>接口入参：Json，以signature代替私钥</p>
<div class="highlight-java notranslate"><div class="highlight"><pre><span></span><span class="o">{</span>
    <span class="s">&quot;functionArg&quot;</span><span class="o">:</span> <span class="o">{</span>
        <span class="s">&quot;cptId&quot;</span><span class="o">:</span> <span class="mi">10</span><span class="o">,</span>
        <span class="s">&quot;issuer&quot;</span><span class="o">:</span> <span class="s">&quot;did:weid:0xfd28ad212a2de77fee518b4914b8579a40c601fa&quot;</span><span class="o">,</span>
        <span class="s">&quot;expirationDate&quot;</span><span class="o">:</span> <span class="s">&quot;2019-04-18T21:12:33Z&quot;</span><span class="o">,</span>
        <span class="s">&quot;claim&quot;</span><span class="o">:</span> <span class="o">{</span>
            <span class="s">&quot;name&quot;</span><span class="o">:</span> <span class="s">&quot;zhang san&quot;</span><span class="o">,</span>
            <span class="s">&quot;gender&quot;</span><span class="o">:</span> <span class="s">&quot;F&quot;</span><span class="o">,</span>
            <span class="s">&quot;age&quot;</span><span class="o">:</span> <span class="mi">18</span>
        <span class="o">},</span>
    <span class="o">},</span>
    <span class="s">&quot;transactionArg&quot;</span><span class="o">:</span> <span class="o">{</span>
        <span class="s">&quot;invokerWeId&quot;</span><span class="o">:</span> <span class="s">&quot;did:weid:0xfd28ad212a2de77fee518b4914b8579a40c601fa&quot;</span>
    <span class="o">},</span>
    <span class="s">&quot;functionName&quot;</span><span class="o">:</span> <span class="s">&quot;createCredential&quot;</span><span class="o">,</span>
    <span class="s">&quot;v&quot;</span><span class="o">:</span> <span class="s">&quot;1.0.0&quot;</span>
<span class="o">}</span>
</pre></div>
</div>
<p>接口返回: application/json</p>
<table class="colwidths-given docutils align-default">
<colgroup>
<col style="width: 38%" />
<col style="width: 63%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>Key</p></th>
<th class="head"><p>Value</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>ErrorCode</p></td>
<td><p>错误码，0表示成功</p></td>
</tr>
<tr class="row-odd"><td><p>ErrorMessage</p></td>
<td><p>错误信息</p></td>
</tr>
<tr class="row-even"><td><p>respBody</p></td>
<td><p>完整的Credential信息</p></td>
</tr>
</tbody>
</table>
<p>接口返回示例:</p>
<div class="highlight-java notranslate"><div class="highlight"><pre><span></span><span class="o">{</span>
  <span class="s">&quot;respBody&quot;</span><span class="o">:</span> <span class="o">{</span>
      <span class="s">&quot;@context&quot;</span><span class="o">:</span> <span class="s">&quot;https://github.com/WeBankBlockchain/WeIdentity/blob/master/context/v1&quot;</span><span class="o">,</span>
      <span class="s">&quot;claim&quot;</span><span class="o">:</span> <span class="o">{</span>
          <span class="s">&quot;content&quot;</span><span class="o">:</span> <span class="s">&quot;b1016358-cf72-42be-9f4b-a18fca610fca&quot;</span><span class="o">,</span>
          <span class="s">&quot;receiver&quot;</span><span class="o">:</span> <span class="s">&quot;did:weid:101:0x7ed16eca3b0737227bc986dd0f2851f644cf4754&quot;</span><span class="o">,</span>
          <span class="s">&quot;weid&quot;</span><span class="o">:</span> <span class="s">&quot;did:weid:101:0xfd28ad212a2de77fee518b4914b8579a40c601fa&quot;</span>
      <span class="o">},</span>
      <span class="s">&quot;cptId&quot;</span><span class="o">:</span> <span class="mi">2000156</span><span class="o">,</span>
      <span class="s">&quot;expirationDate&quot;</span><span class="o">:</span> <span class="s">&quot;2100-04-18T21:12:33Z&quot;</span><span class="o">,</span>
      <span class="s">&quot;id&quot;</span><span class="o">:</span> <span class="s">&quot;da6fbdbb-b5fa-4fbe-8b0c-8659da2d181b&quot;</span><span class="o">,</span>
      <span class="s">&quot;issuanceDate&quot;</span><span class="o">:</span> <span class="s">&quot;2020-02-06T22:24:00Z&quot;</span><span class="o">,</span>
      <span class="s">&quot;issuer&quot;</span><span class="o">:</span> <span class="s">&quot;did:weid:101:0xfd28ad212a2de77fee518b4914b8579a40c601fa&quot;</span><span class="o">,</span>
      <span class="s">&quot;proof&quot;</span><span class="o">:</span> <span class="o">{</span>
          <span class="s">&quot;created&quot;</span><span class="o">:</span> <span class="s">&quot;1580999040000&quot;</span><span class="o">,</span>
          <span class="s">&quot;creator&quot;</span><span class="o">:</span> <span class="s">&quot;did:weid:101:0xfd28ad212a2de77fee518b4914b8579a40c601fa&quot;</span><span class="o">,</span>
          <span class="s">&quot;signature&quot;</span><span class="o">:</span> <span class="s">&quot;G0XzzLY+MqUAo3xXkS3lxVsgFLnTtvdXM24p+G5hSNNMSIa5vAXYXXKl+Y79CO2ho5DIGPPvSs2hvAixmfIJGbw=&quot;</span><span class="o">,</span>
          <span class="s">&quot;type&quot;</span><span class="o">:</span> <span class="s">&quot;Secp256k1&quot;</span>
      <span class="o">}</span>
  <span class="o">},</span>
  <span class="s">&quot;errorCode&quot;</span><span class="o">:</span> <span class="mi">0</span><span class="o">,</span>
  <span class="s">&quot;errorMessage&quot;</span><span class="o">:</span> <span class="s">&quot;success&quot;</span>
<span class="o">}</span>
</pre></div>
</div>
</div>
<div class="section" id="id4">
<h3>9. 验证Credential<a class="headerlink" href="#id4" title="永久链接至标题">¶</a></h3>
<p>调用接口：</p>
<table class="colwidths-given docutils align-default">
<colgroup>
<col style="width: 38%" />
<col style="width: 63%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>标题</p></th>
<th class="head"><p>描述</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>接口名</p></td>
<td><p>weid/api/invoke</p></td>
</tr>
<tr class="row-odd"><td><p>Method</p></td>
<td><p>POST</p></td>
</tr>
<tr class="row-even"><td><p>Content-Type</p></td>
<td><p>application/json</p></td>
</tr>
</tbody>
</table>
<p>接口入参：</p>
<table class="colwidths-given docutils align-default">
<colgroup>
<col style="width: 27%" />
<col style="width: 55%" />
<col style="width: 18%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>Key</p></th>
<th class="head"><p>Value</p></th>
<th class="head"><p>Required</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>functionName</p></td>
<td><p>verifyCredential</p></td>
<td><p>Y</p></td>
</tr>
<tr class="row-odd"><td><p>functionArg</p></td>
<td></td>
<td><p>Y</p></td>
</tr>
<tr class="row-even"><td><p>functionArg.claim</p></td>
<td><p>claim Json 结构体，与SDK直接调用的方式入参一致，下同</p></td>
<td><p>Y</p></td>
</tr>
<tr class="row-odd"><td><p>functionArg.cptId</p></td>
<td><p>CPT ID</p></td>
<td><p>Y</p></td>
</tr>
<tr class="row-even"><td><p>functionArg.context</p></td>
<td><p>context值</p></td>
<td><p>Y</p></td>
</tr>
<tr class="row-odd"><td><p>functionArg.uuid</p></td>
<td><p>Credential的UUID</p></td>
<td><p>Y</p></td>
</tr>
<tr class="row-even"><td><p>functionArg.issuer</p></td>
<td><p>issuer WeIdentity DID</p></td>
<td><p>Y</p></td>
</tr>
<tr class="row-odd"><td><p>functionArg.issuranceDate</p></td>
<td><p>颁发时间</p></td>
<td><p>Y</p></td>
</tr>
<tr class="row-even"><td><p>functionArg.expirationDate</p></td>
<td><p>过期时间</p></td>
<td><p>Y</p></td>
</tr>
<tr class="row-odd"><td><p>functionArg.proof</p></td>
<td><p>Credential签名结构体</p></td>
<td><p>Y</p></td>
</tr>
<tr class="row-even"><td><p>transactionArg</p></td>
<td></td>
<td><p>N，传空</p></td>
</tr>
<tr class="row-odd"><td><p>v</p></td>
<td><p>版本号</p></td>
<td><p>Y</p></td>
</tr>
</tbody>
</table>
<p>接口入参：</p>
<div class="highlight-java notranslate"><div class="highlight"><pre><span></span><span class="o">{</span>
    <span class="s">&quot;functionArg&quot;</span><span class="o">:</span> <span class="o">{</span>
      <span class="s">&quot;@context&quot;</span><span class="o">:</span> <span class="s">&quot;https://github.com/WeBankBlockchain/WeIdentity/blob/master/context/v1&quot;</span><span class="o">,</span>
      <span class="s">&quot;claim&quot;</span><span class="o">:</span> <span class="o">{</span>
          <span class="s">&quot;content&quot;</span><span class="o">:</span> <span class="s">&quot;b1016358-cf72-42be-9f4b-a18fca610fca&quot;</span><span class="o">,</span>
          <span class="s">&quot;receiver&quot;</span><span class="o">:</span> <span class="s">&quot;did:weid:101:0x7ed16eca3b0737227bc986dd0f2851f644cf4754&quot;</span><span class="o">,</span>
          <span class="s">&quot;weid&quot;</span><span class="o">:</span> <span class="s">&quot;did:weid:101:0xfd28ad212a2de77fee518b4914b8579a40c601fa&quot;</span>
      <span class="o">},</span>
      <span class="s">&quot;cptId&quot;</span><span class="o">:</span> <span class="mi">2000156</span><span class="o">,</span>
      <span class="s">&quot;expirationDate&quot;</span><span class="o">:</span> <span class="s">&quot;2100-04-18T21:12:33Z&quot;</span><span class="o">,</span>
      <span class="s">&quot;id&quot;</span><span class="o">:</span> <span class="s">&quot;da6fbdbb-b5fa-4fbe-8b0c-8659da2d181b&quot;</span><span class="o">,</span>
      <span class="s">&quot;issuanceDate&quot;</span><span class="o">:</span> <span class="s">&quot;2020-02-06T22:24:00Z&quot;</span><span class="o">,</span>
      <span class="s">&quot;issuer&quot;</span><span class="o">:</span> <span class="s">&quot;did:weid:101:0xfd28ad212a2de77fee518b4914b8579a40c601fa&quot;</span><span class="o">,</span>
      <span class="s">&quot;proof&quot;</span><span class="o">:</span> <span class="o">{</span>
          <span class="s">&quot;created&quot;</span><span class="o">:</span> <span class="s">&quot;1580999040000&quot;</span><span class="o">,</span>
          <span class="s">&quot;creator&quot;</span><span class="o">:</span> <span class="s">&quot;did:weid:101:0xfd28ad212a2de77fee518b4914b8579a40c601fa&quot;</span><span class="o">,</span>
          <span class="s">&quot;signature&quot;</span><span class="o">:</span> <span class="s">&quot;G0XzzLY+MqUAo3xXkS3lxVsgFLnTtvdXM24p+G5hSNNMSIa5vAXYXXKl+Y79CO2ho5DIGPPvSs2hvAixmfIJGbw=&quot;</span><span class="o">,</span>
          <span class="s">&quot;type&quot;</span><span class="o">:</span> <span class="s">&quot;Secp256k1&quot;</span>
      <span class="o">}</span>
    <span class="o">},</span>
    <span class="s">&quot;transactionArg&quot;</span><span class="o">:</span> <span class="o">{</span>
    <span class="o">},</span>
    <span class="s">&quot;functionName&quot;</span><span class="o">:</span> <span class="s">&quot;verifyCredential&quot;</span>
    <span class="s">&quot;v&quot;</span><span class="o">:</span> <span class="s">&quot;1.0.0&quot;</span>
<span class="o">}</span>
</pre></div>
</div>
<p>接口返回: application/json</p>
<table class="colwidths-given docutils align-default">
<colgroup>
<col style="width: 38%" />
<col style="width: 63%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>Key</p></th>
<th class="head"><p>Value</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>ErrorCode</p></td>
<td><p>错误码，0表示成功</p></td>
</tr>
<tr class="row-odd"><td><p>ErrorMessage</p></td>
<td><p>错误信息</p></td>
</tr>
<tr class="row-even"><td><p>respBody</p></td>
<td><p>True/False</p></td>
</tr>
</tbody>
</table>
<p>接口返回：</p>
<div class="highlight-java notranslate"><div class="highlight"><pre><span></span><span class="o">{</span>
    <span class="s">&quot;respBody&quot;</span><span class="o">:</span> <span class="kc">true</span><span class="o">,</span>
    <span class="s">&quot;ErrorCode&quot;</span><span class="o">:</span> <span class="mi">0</span><span class="o">,</span>
    <span class="s">&quot;ErrorMessage&quot;</span><span class="o">:</span> <span class="s">&quot;success&quot;</span>
<span class="o">}</span>
</pre></div>
</div>
</div>
<div class="section" id="credentialpojo">
<h3>10. 创建CredentialPojo<a class="headerlink" href="#credentialpojo" title="永久链接至标题">¶</a></h3>
<p>调用接口：</p>
<table class="colwidths-given docutils align-default">
<colgroup>
<col style="width: 38%" />
<col style="width: 63%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>标题</p></th>
<th class="head"><p>描述</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>接口名</p></td>
<td><p>weid/api/invoke</p></td>
</tr>
<tr class="row-odd"><td><p>Method</p></td>
<td><p>POST</p></td>
</tr>
<tr class="row-even"><td><p>Content-Type</p></td>
<td><p>application/json</p></td>
</tr>
</tbody>
</table>
<p>接口入参：</p>
<table class="colwidths-given docutils align-default">
<colgroup>
<col style="width: 27%" />
<col style="width: 55%" />
<col style="width: 18%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>Key</p></th>
<th class="head"><p>Value</p></th>
<th class="head"><p>Required</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>functionName</p></td>
<td><p>createCredentialPojo</p></td>
<td><p>Y</p></td>
</tr>
<tr class="row-odd"><td><p>functionArg</p></td>
<td></td>
<td><p>Y</p></td>
</tr>
<tr class="row-even"><td><p>functionArg.claim</p></td>
<td><p>claim Json结构体，与SDK直接调用的方式入参一致，下同</p></td>
<td><p>Y</p></td>
</tr>
<tr class="row-odd"><td><p>functionArg.cptId</p></td>
<td><p>CPT ID</p></td>
<td><p>Y</p></td>
</tr>
<tr class="row-even"><td><p>functionArg.issuer</p></td>
<td><p>issuer WeIdentity DID</p></td>
<td><p>Y</p></td>
</tr>
<tr class="row-odd"><td><p>functionArg.expirationDate</p></td>
<td><p>过期时间（使用UTC格式）</p></td>
<td><p>Y</p></td>
</tr>
<tr class="row-even"><td><p>transactionArg</p></td>
<td></td>
<td><p>Y</p></td>
</tr>
<tr class="row-odd"><td><p>transactionArg.invokerWeId</p></td>
<td><p>用于索引私钥的WeIdentity DID，服务器端会凭此找到所托管的私钥</p></td>
<td><p>Y</p></td>
</tr>
<tr class="row-even"><td><p>v</p></td>
<td><p>版本号</p></td>
<td><p>Y</p></td>
</tr>
</tbody>
</table>
<p>接口入参：Json，以signature代替私钥</p>
<div class="highlight-java notranslate"><div class="highlight"><pre><span></span><span class="o">{</span>
    <span class="s">&quot;functionArg&quot;</span><span class="o">:</span> <span class="o">{</span>
        <span class="s">&quot;cptId&quot;</span><span class="o">:</span> <span class="mi">10</span><span class="o">,</span>
        <span class="s">&quot;issuer&quot;</span><span class="o">:</span> <span class="s">&quot;did:weid:0xfd28ad212a2de77fee518b4914b8579a40c601fa&quot;</span><span class="o">,</span>
        <span class="s">&quot;expirationDate&quot;</span><span class="o">:</span> <span class="s">&quot;2019-04-18T21:12:33Z&quot;</span><span class="o">,</span>
        <span class="s">&quot;claim&quot;</span><span class="o">:</span> <span class="o">{</span>
            <span class="s">&quot;name&quot;</span><span class="o">:</span> <span class="s">&quot;zhang san&quot;</span><span class="o">,</span>
            <span class="s">&quot;gender&quot;</span><span class="o">:</span> <span class="s">&quot;F&quot;</span><span class="o">,</span>
            <span class="s">&quot;age&quot;</span><span class="o">:</span> <span class="mi">18</span>
        <span class="o">},</span>
    <span class="o">},</span>
    <span class="s">&quot;transactionArg&quot;</span><span class="o">:</span> <span class="o">{</span>
        <span class="s">&quot;invokerWeId&quot;</span><span class="o">:</span> <span class="s">&quot;did:weid:0xfd28ad212a2de77fee518b4914b8579a40c601fa&quot;</span>
    <span class="o">},</span>
    <span class="s">&quot;functionName&quot;</span><span class="o">:</span> <span class="s">&quot;createCredentialPojo&quot;</span><span class="o">,</span>
    <span class="s">&quot;v&quot;</span><span class="o">:</span> <span class="s">&quot;1.0.0&quot;</span>
<span class="o">}</span>
</pre></div>
</div>
<p>接口返回: application/json</p>
<table class="colwidths-given docutils align-default">
<colgroup>
<col style="width: 38%" />
<col style="width: 63%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>Key</p></th>
<th class="head"><p>Value</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>ErrorCode</p></td>
<td><p>错误码，0表示成功</p></td>
</tr>
<tr class="row-odd"><td><p>ErrorMessage</p></td>
<td><p>错误信息</p></td>
</tr>
<tr class="row-even"><td><p>respBody</p></td>
<td><p>完整的CredentialPojo信息</p></td>
</tr>
</tbody>
</table>
<p>接口返回示例:</p>
<div class="highlight-java notranslate"><div class="highlight"><pre><span></span><span class="o">{</span>
  <span class="s">&quot;respBody&quot;</span><span class="o">:</span> <span class="o">{</span>
      <span class="s">&quot;cptId&quot;</span><span class="o">:</span> <span class="mi">2000156</span><span class="o">,</span>
      <span class="s">&quot;issuanceDate&quot;</span><span class="o">:</span> <span class="mi">1580996777</span><span class="o">,</span>
      <span class="s">&quot;context&quot;</span><span class="o">:</span> <span class="s">&quot;https://github.com/WeBankBlockchain/WeIdentity/blob/master/context/v1&quot;</span><span class="o">,</span>
      <span class="s">&quot;claim&quot;</span><span class="o">:</span> <span class="o">{</span>
          <span class="s">&quot;content&quot;</span><span class="o">:</span> <span class="s">&quot;b1016358-cf72-42be-9f4b-a18fca610fca&quot;</span><span class="o">,</span>
          <span class="s">&quot;receiver&quot;</span><span class="o">:</span> <span class="s">&quot;did:weid:101:0x7ed16eca3b0737227bc986dd0f2851f644cf4754&quot;</span><span class="o">,</span>
          <span class="s">&quot;weid&quot;</span><span class="o">:</span> <span class="s">&quot;did:weid:101:0xfd28ad212a2de77fee518b4914b8579a40c601fa&quot;</span>
      <span class="o">},</span>
      <span class="s">&quot;id&quot;</span><span class="o">:</span> <span class="s">&quot;21d10ab1-75fe-4733-9f1d-f0bad71b5922&quot;</span><span class="o">,</span>
      <span class="s">&quot;proof&quot;</span><span class="o">:</span> <span class="o">{</span>
          <span class="s">&quot;created&quot;</span><span class="o">:</span> <span class="mi">1580996777</span><span class="o">,</span>
          <span class="s">&quot;creator&quot;</span><span class="o">:</span> <span class="s">&quot;did:weid:101:0xfd28ad212a2de77fee518b4914b8579a40c601fa#keys-0&quot;</span><span class="o">,</span>
          <span class="s">&quot;salt&quot;</span><span class="o">:</span> <span class="o">{</span>
              <span class="s">&quot;content&quot;</span><span class="o">:</span> <span class="s">&quot;ncZ5F&quot;</span><span class="o">,</span>
              <span class="s">&quot;receiver&quot;</span><span class="o">:</span> <span class="s">&quot;L0c40&quot;</span><span class="o">,</span>
              <span class="s">&quot;weid&quot;</span><span class="o">:</span> <span class="s">&quot;I4aop&quot;</span>
          <span class="o">},</span>
          <span class="s">&quot;signatureValue&quot;</span><span class="o">:</span> <span class="s">&quot;HEugP13uDVBg2G0kmmwbTkQXobsrWNqtGQJW6BoHU2Q2VQpwVhK382dArRMFN6BDq7ogozYBRC15QR8ueX5G3t8=&quot;</span><span class="o">,</span>
          <span class="s">&quot;type&quot;</span><span class="o">:</span> <span class="s">&quot;Secp256k1&quot;</span>
      <span class="o">},</span>
      <span class="s">&quot;type&quot;</span><span class="o">:</span> <span class="o">[</span>
          <span class="s">&quot;VerifiableCredential&quot;</span><span class="o">,</span>
          <span class="s">&quot;hashTree&quot;</span>
      <span class="o">],</span>
      <span class="s">&quot;issuer&quot;</span><span class="o">:</span> <span class="s">&quot;did:weid:101:0xfd28ad212a2de77fee518b4914b8579a40c601fa&quot;</span><span class="o">,</span>
      <span class="s">&quot;expirationDate&quot;</span><span class="o">:</span> <span class="mi">4111737153</span>
  <span class="o">},</span>
  <span class="s">&quot;errorCode&quot;</span><span class="o">:</span> <span class="mi">0</span><span class="o">,</span>
  <span class="s">&quot;errorMessage&quot;</span><span class="o">:</span> <span class="s">&quot;success&quot;</span>
<span class="o">}</span>
</pre></div>
</div>
</div>
<div class="section" id="id5">
<h3>11. 验证CredentialPojo<a class="headerlink" href="#id5" title="永久链接至标题">¶</a></h3>
<p>调用接口：</p>
<table class="colwidths-given docutils align-default">
<colgroup>
<col style="width: 38%" />
<col style="width: 63%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>标题</p></th>
<th class="head"><p>描述</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>接口名</p></td>
<td><p>weid/api/invoke</p></td>
</tr>
<tr class="row-odd"><td><p>Method</p></td>
<td><p>POST</p></td>
</tr>
<tr class="row-even"><td><p>Content-Type</p></td>
<td><p>application/json</p></td>
</tr>
</tbody>
</table>
<p>接口入参：</p>
<table class="colwidths-given docutils align-default">
<colgroup>
<col style="width: 27%" />
<col style="width: 55%" />
<col style="width: 18%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>Key</p></th>
<th class="head"><p>Value</p></th>
<th class="head"><p>Required</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>functionName</p></td>
<td><p>verifyCredentialPojo</p></td>
<td><p>Y</p></td>
</tr>
<tr class="row-odd"><td><p>functionArg</p></td>
<td></td>
<td><p>Y</p></td>
</tr>
<tr class="row-even"><td><p>functionArg.claim</p></td>
<td><p>claim Json 结构体，与SDK直接调用的方式入参要求一致，下同</p></td>
<td><p>Y</p></td>
</tr>
<tr class="row-odd"><td><p>functionArg.cptId</p></td>
<td><p>CPT ID</p></td>
<td><p>Y</p></td>
</tr>
<tr class="row-even"><td><p>functionArg.context</p></td>
<td><p>context值</p></td>
<td><p>Y</p></td>
</tr>
<tr class="row-odd"><td><p>functionArg.uuid</p></td>
<td><p>CredentialPojo的UUID</p></td>
<td><p>Y</p></td>
</tr>
<tr class="row-even"><td><p>functionArg.issuer</p></td>
<td><p>issuer WeIdentity DID</p></td>
<td><p>Y</p></td>
</tr>
<tr class="row-odd"><td><p>functionArg.issuranceDate</p></td>
<td><p>颁发时间</p></td>
<td><p>Y</p></td>
</tr>
<tr class="row-even"><td><p>functionArg.expirationDate</p></td>
<td><p>过期时间</p></td>
<td><p>Y</p></td>
</tr>
<tr class="row-odd"><td><p>functionArg.proof</p></td>
<td><p>Credential签名值</p></td>
<td><p>Y</p></td>
</tr>
<tr class="row-even"><td><p>transactionArg</p></td>
<td></td>
<td><p>N，传空</p></td>
</tr>
<tr class="row-odd"><td><p>v</p></td>
<td><p>版本号</p></td>
<td><p>Y</p></td>
</tr>
</tbody>
</table>
<p>接口入参：</p>
<div class="highlight-java notranslate"><div class="highlight"><pre><span></span><span class="o">{</span>
    <span class="s">&quot;functionArg&quot;</span><span class="o">:</span> <span class="o">{</span>
      <span class="s">&quot;cptId&quot;</span><span class="o">:</span> <span class="mi">2000156</span><span class="o">,</span>
      <span class="s">&quot;issuanceDate&quot;</span><span class="o">:</span> <span class="mi">1580996777</span><span class="o">,</span>
      <span class="s">&quot;context&quot;</span><span class="o">:</span> <span class="s">&quot;https://github.com/WeBankBlockchain/WeIdentity/blob/master/context/v1&quot;</span><span class="o">,</span>
      <span class="s">&quot;claim&quot;</span><span class="o">:</span> <span class="o">{</span>
          <span class="s">&quot;content&quot;</span><span class="o">:</span> <span class="s">&quot;b1016358-cf72-42be-9f4b-a18fca610fca&quot;</span><span class="o">,</span>
          <span class="s">&quot;receiver&quot;</span><span class="o">:</span> <span class="s">&quot;did:weid:101:0x7ed16eca3b0737227bc986dd0f2851f644cf4754&quot;</span><span class="o">,</span>
          <span class="s">&quot;weid&quot;</span><span class="o">:</span> <span class="s">&quot;did:weid:101:0xfd28ad212a2de77fee518b4914b8579a40c601fa&quot;</span>
      <span class="o">},</span>
      <span class="s">&quot;id&quot;</span><span class="o">:</span> <span class="s">&quot;21d10ab1-75fe-4733-9f1d-f0bad71b5922&quot;</span><span class="o">,</span>
      <span class="s">&quot;proof&quot;</span><span class="o">:</span> <span class="o">{</span>
          <span class="s">&quot;created&quot;</span><span class="o">:</span> <span class="mi">1580996777</span><span class="o">,</span>
          <span class="s">&quot;creator&quot;</span><span class="o">:</span> <span class="s">&quot;did:weid:101:0xfd28ad212a2de77fee518b4914b8579a40c601fa#keys-0&quot;</span><span class="o">,</span>
          <span class="s">&quot;salt&quot;</span><span class="o">:</span> <span class="o">{</span>
              <span class="s">&quot;content&quot;</span><span class="o">:</span> <span class="s">&quot;ncZ5F&quot;</span><span class="o">,</span>
              <span class="s">&quot;receiver&quot;</span><span class="o">:</span> <span class="s">&quot;L0c40&quot;</span><span class="o">,</span>
              <span class="s">&quot;weid&quot;</span><span class="o">:</span> <span class="s">&quot;I4aop&quot;</span>
          <span class="o">},</span>
          <span class="s">&quot;signatureValue&quot;</span><span class="o">:</span> <span class="s">&quot;HEugP13uDVBg2G0kmmwbTkQXobsrWNqtGQJW6BoHU2Q2VQpwVhK382dArRMFN6BDq7ogozYBRC15QR8ueX5G3t8=&quot;</span><span class="o">,</span>
          <span class="s">&quot;type&quot;</span><span class="o">:</span> <span class="s">&quot;Secp256k1&quot;</span>
      <span class="o">},</span>
      <span class="s">&quot;type&quot;</span><span class="o">:</span> <span class="o">[</span>
          <span class="s">&quot;VerifiableCredential&quot;</span><span class="o">,</span>
          <span class="s">&quot;hashTree&quot;</span>
      <span class="o">],</span>
      <span class="s">&quot;issuer&quot;</span><span class="o">:</span> <span class="s">&quot;did:weid:101:0xfd28ad212a2de77fee518b4914b8579a40c601fa&quot;</span><span class="o">,</span>
      <span class="s">&quot;expirationDate&quot;</span><span class="o">:</span> <span class="mi">4111737153</span>
    <span class="o">},</span>
    <span class="s">&quot;transactionArg&quot;</span><span class="o">:</span> <span class="o">{</span>
    <span class="o">},</span>
    <span class="s">&quot;functionName&quot;</span><span class="o">:</span> <span class="s">&quot;verifyCredentialPojo&quot;</span>
    <span class="s">&quot;v&quot;</span><span class="o">:</span> <span class="s">&quot;1.0.0&quot;</span>
<span class="o">}</span>
</pre></div>
</div>
<p>接口返回: application/json</p>
<table class="colwidths-given docutils align-default">
<colgroup>
<col style="width: 38%" />
<col style="width: 63%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>Key</p></th>
<th class="head"><p>Value</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>ErrorCode</p></td>
<td><p>错误码，0表示成功</p></td>
</tr>
<tr class="row-odd"><td><p>ErrorMessage</p></td>
<td><p>错误信息</p></td>
</tr>
<tr class="row-even"><td><p>respBody</p></td>
<td><p>True/False</p></td>
</tr>
</tbody>
</table>
<p>接口返回：</p>
<div class="highlight-java notranslate"><div class="highlight"><pre><span></span><span class="o">{</span>
    <span class="s">&quot;respBody&quot;</span><span class="o">:</span> <span class="kc">true</span><span class="o">,</span>
    <span class="s">&quot;ErrorCode&quot;</span><span class="o">:</span> <span class="mi">0</span><span class="o">,</span>
    <span class="s">&quot;ErrorMessage&quot;</span><span class="o">:</span> <span class="s">&quot;success&quot;</span>
<span class="o">}</span>
</pre></div>
</div>
</div>
</div>
<div class="section" id="id6">
<h2>基于轻客户端模式的RestService API<a class="headerlink" href="#id6" title="永久链接至标题">¶</a></h2>
<div class="section" id="id7">
<h3>1. 总体介绍<a class="headerlink" href="#id7" title="永久链接至标题">¶</a></h3>
<p>基于轻客户端模式的API的入参形式与基于私钥托管模式的API相同，也是满足以下格式的json字符串。
最大的区别在于，流程包括两次交互，第一次是轻客户端提供接口参数发给RestService服务端，后者进行组装、编码区块链原始交易串并返回；第二次是轻客户端在本地使用自己的私钥，对原始交易串进行符合ECDSA的sha3签名，发给RestService服务端，后者打包并直接执行交易。</p>
<ul class="simple">
<li><p>第一次交互</p></li>
</ul>
<p>调用接口：</p>
<table class="colwidths-given docutils align-default">
<colgroup>
<col style="width: 38%" />
<col style="width: 63%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>标题</p></th>
<th class="head"><p>描述</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>接口名</p></td>
<td><p>weid/api/encode</p></td>
</tr>
<tr class="row-odd"><td><p>Method</p></td>
<td><p>POST</p></td>
</tr>
<tr class="row-even"><td><p>Content-Type</p></td>
<td><p>application/json</p></td>
</tr>
</tbody>
</table>
<p>接口入参（Body）：</p>
<div class="highlight-java notranslate"><div class="highlight"><pre><span></span><span class="o">{</span>
    <span class="s">&quot;functionArg&quot;</span><span class="o">:</span> <span class="n">随调用SDK方法而变的入参json字符串</span> <span class="o">{</span>
        <span class="o">...</span>
    <span class="o">},</span>
    <span class="s">&quot;transactionArg&quot;</span><span class="o">:</span> <span class="n">交易参数json字符串</span> <span class="o">{</span>
        <span class="s">&quot;nonce&quot;</span><span class="o">:</span> <span class="n">用于防止重放攻击的交易随机数</span>
    <span class="o">}</span>
    <span class="s">&quot;functionName&quot;</span><span class="o">:</span> <span class="n">调用SDK方法名</span>
    <span class="s">&quot;v&quot;</span><span class="o">:</span> <span class="n">API版本号</span>
<span class="o">}</span>
</pre></div>
</div>
<p>参数说明：</p>
<ul class="simple">
<li><p>functionArg是随不同的SDK调用方法而变的，具体的参数可以查看SDK接口文档；后文会为每个所提及的接口给出对应的链接</p></li>
<li><dl class="simple">
<dt>transactionArg仅包括一个变量nonce，用于防止重放攻击的交易随机数，您可以使用RestService jar的getNonce()，或其他类似方法生成此随机数。</dt><dd><ul>
<li><p>必需，且必须妥善保存，这个nonce在第二次交互中还会用到</p></li>
</ul>
</dd>
</dl>
</li>
<li><p>functionName是调用的SDK方法名，用于决定具体调用WeIdentity Java SDK的什么功能</p></li>
<li><p>v是调用的API方法版本</p></li>
</ul>
<p>第一次交互的接口返回是以下格式的json字符串：</p>
<div class="highlight-java notranslate"><div class="highlight"><pre><span></span>{
    &quot;respBody&quot;: {
        &quot;encodedTransaction&quot;: 基于Base64编码的原始交易串信息
        &quot;data&quot;: 交易特征值
    }
    &quot;ErrorCode&quot;: 错误码
    &quot;ErrorMessage&quot;: 错误信息，成功时为&quot;success&quot;
}
</pre></div>
</div>
<p>返回结构体包含encodedTransaction和data两项。
调用者随后需要使用自己的私钥对encodeTransaction进行交易签名，然后使用Base64对其进行编码，和data、nonce一起待用，
进行第二次交互。</p>
<div class="admonition note">
<p class="admonition-title">注解</p>
<p>请注意使用的ECDSA签名算法的编码格式。WeID Java SDK所使用的是椭圆曲线Secp256k1算法，这也是WeID Go轻客户端的默认算法。一般来说，ECDSA的签名算法会生成R，S，V三个值，其中R和S是32个字节的二进制字节数组，而V，以太坊原生的Secp256k1算法的结果一般是0或1。</p>
</div>
<div class="admonition note">
<p class="admonition-title">注解</p>
<p>当您生成签名的R，S，V之后，您需要将R，S，V存入一个65个字节长的二进制字节数组，再进行Base64编码方可正确由RestService解析。RestService只接受两种组成方式：
1. 按照R, S, V的顺序拼接成一个65个字节长的数组并使用Base64编码（这是WeID Go轻客户端默认方式，此时V的值为0或1）
2. 按照V+27, R, S的顺序拼接成一个65个字节长的数组并使用Base64编码（这是WeID Java SDK默认序列化方式，此时V的值为27或28）</p>
</div>
<p>您可以参考Java侧的客户端代码，使用默认Secp256k1私钥进行签名和Base64编码的范例代码见下：</p>
<div class="highlight-java notranslate"><div class="highlight"><pre><span></span><span class="c1">// 依赖web3sdk 2.2.2和weid-java-sdk 1.5</span>
<span class="kt">byte</span><span class="o">[]</span> <span class="n">encodedTransaction</span> <span class="o">=</span> <span class="n">DataToolUtils</span>
        <span class="o">.</span><span class="na">base64Decode</span><span class="o">(</span><span class="s">&quot;&lt;encodedTransaction的值&gt;&quot;</span><span class="o">.</span><span class="na">getBytes</span><span class="o">());</span>
    <span class="n">SignatureData</span> <span class="n">clientSignedData</span> <span class="o">=</span> <span class="n">Sign</span><span class="o">.</span><span class="na">getSignInterface</span><span class="o">().</span><span class="na">signMessage</span><span class="o">(</span><span class="n">encodedTransactionClient</span><span class="o">,</span> <span class="n">ecKeyPair</span><span class="o">);</span>
    <span class="n">String</span> <span class="n">base64SignedMsg</span> <span class="o">=</span> <span class="k">new</span> <span class="n">String</span><span class="o">(</span>
        <span class="n">DataToolUtils</span><span class="o">.</span><span class="na">base64Encode</span><span class="o">(</span><span class="n">TransactionEncoderUtilV2</span><span class="o">.</span><span class="na">simpleSignatureSerialization</span><span class="o">(</span><span class="n">clientSignedData</span><span class="o">)));</span>
</pre></div>
</div>
<ul class="simple">
<li><p>第二次交互</p></li>
</ul>
<p>调用接口：</p>
<table class="colwidths-given docutils align-default">
<colgroup>
<col style="width: 38%" />
<col style="width: 63%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>标题</p></th>
<th class="head"><p>描述</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>接口名</p></td>
<td><p>weid/api/transact</p></td>
</tr>
<tr class="row-odd"><td><p>Method</p></td>
<td><p>POST</p></td>
</tr>
<tr class="row-even"><td><p>Content-Type</p></td>
<td><p>application/json</p></td>
</tr>
</tbody>
</table>
<p>接口入参：</p>
<div class="highlight-java notranslate"><div class="highlight"><pre><span></span>{
    &quot;functionArg&quot;: 空 {
    },
    &quot;transactionArg&quot;: 交易参数json字符串 {
        &quot;nonce&quot;: 用于防止重放攻击的交易随机数
        &quot;data&quot;: 交易特征值，需和第一步中返回值一致
        &quot;signedMessage&quot;: 基于Base64编码的、使用私钥签名之后的encodedTransaction签名值
    }
    &quot;functionName&quot;: 调用SDK方法名
    &quot;v&quot;: API版本号
}
</pre></div>
</div>
<p>这一步的目的是将已签名交易的参数发给RestService，并由后者将交易打包上链。参数说明：</p>
<ul class="simple">
<li><p>functionArg此时为空</p></li>
<li><p>transactionArg包括第一次交互起始阶段生成的nonce、第一次交互收到的data，以及最重要的，使用调用者本地私钥签名并通过Base64编码的encodedTransaction的签名值</p></li>
<li><p>functionName是调用的SDK方法名，用于决定具体调用WeIdentity Java SDK的什么功能</p></li>
<li><p>v是调用的API方法版本</p></li>
</ul>
<p>第二次交互的接口返回是以下格式的json字符串：</p>
<div class="highlight-java notranslate"><div class="highlight"><pre><span></span>{
    &quot;respBody&quot;: 随调用SDK方法而变的输出值json字符串 {
    }
    &quot;ErrorCode&quot;: 错误码
    &quot;ErrorMessage&quot;: 错误信息，成功时为&quot;success&quot;
}
</pre></div>
</div>
<p>其中具体的输出值result亦是随不同的SDK调用方法而变的。
可以看到，基于轻客户端的交易方式，本质上，是因为签名操作必须在本地完成，因此将原始交易串分成了两次交互完成。
基于轻客户端的每个API的入参，也仅仅在第一次交互中不同。因此，在下文的介绍中，我们会忽略第二次交互的入参，只提供第一次交互的入参和第二次交互的返回值。</p>
</div>
<div class="section" id="id8">
<h3>2. 创建WeIdentity DID（有参创建方式）<a class="headerlink" href="#id8" title="永久链接至标题">¶</a></h3>
<p>第一次交互，POST /weid/api/encode 的接口入参：</p>
<table class="colwidths-given docutils align-default">
<colgroup>
<col style="width: 27%" />
<col style="width: 55%" />
<col style="width: 18%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>Key</p></th>
<th class="head"><p>Value</p></th>
<th class="head"><p>Required</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>functionName</p></td>
<td><p>createWeId</p></td>
<td><p>Y</p></td>
</tr>
<tr class="row-odd"><td><p>functionArg</p></td>
<td></td>
<td><p>Y</p></td>
</tr>
<tr class="row-even"><td><p>functionArg.publicKey</p></td>
<td><p>ECDSA公钥，需要为10进制的整型数字，以字符串形式传入</p></td>
<td><p>Y</p></td>
</tr>
<tr class="row-odd"><td><p>transactionArg</p></td>
<td></td>
<td><p>Y</p></td>
</tr>
<tr class="row-even"><td><p>transactionArg.nonce</p></td>
<td><p>交易随机数</p></td>
<td><p>Y</p></td>
</tr>
<tr class="row-odd"><td><p>v</p></td>
<td><p>版本号</p></td>
<td><p>Y</p></td>
</tr>
</tbody>
</table>
<p>第一次交互，POST /weid/api/encode 接口入参示例：</p>
<div class="highlight-java notranslate"><div class="highlight"><pre><span></span><span class="o">{</span>
    <span class="s">&quot;functionArg&quot;</span><span class="o">:</span> <span class="o">{</span>
        <span class="s">&quot;publicKey&quot;</span><span class="o">:</span> <span class="s">&quot;712679236821355231513532168231727831978932132185632517152735621683128&quot;</span>
    <span class="o">},</span>
    <span class="s">&quot;transactionArg&quot;</span><span class="o">:</span> <span class="o">{</span>
        <span class="s">&quot;nonce&quot;</span><span class="o">:</span> <span class="s">&quot;1474800601011307365506121304576347479508653499989424346408343855615822146039&quot;</span>
    <span class="o">},</span>
    <span class="s">&quot;functionName&quot;</span><span class="o">:</span> <span class="s">&quot;createWeId&quot;</span><span class="o">,</span>
    <span class="s">&quot;v&quot;</span><span class="o">:</span> <span class="s">&quot;1.0.0&quot;</span>
<span class="o">}</span>
</pre></div>
</div>
<p>第二次交互，POST /weid/api/transact 接口入参示例：</p>
<div class="highlight-java notranslate"><div class="highlight"><pre><span></span><span class="o">{</span>
    <span class="s">&quot;functionArg&quot;</span><span class="o">:</span> <span class="o">{},</span>
    <span class="s">&quot;transactionArg&quot;</span><span class="o">:</span> <span class="o">{</span>
        <span class="s">&quot;nonce&quot;</span><span class="o">:</span> <span class="s">&quot;1474800601011307365506121304576347479508653499989424346408343855615822146039&quot;</span><span class="o">,</span>
        <span class="s">&quot;data&quot;</span><span class="o">:</span> <span class="s">&quot;809812638256c1235b1231000e000000001231287bacf213c&quot;</span><span class="o">,</span>
        <span class="s">&quot;signedMessage&quot;</span><span class="o">:</span> <span class="s">&quot;HEugP13uDVBg2G0kmmwbTkQXobsrWNqtGQJW6BoHU2Q2VQpwVhK382dArRMFN6BDq7ogozYBRC15QR8ueX5G3t8=&quot;</span>
    <span class="o">},</span>
    <span class="s">&quot;functionName&quot;</span><span class="o">:</span> <span class="s">&quot;createWeId&quot;</span><span class="o">,</span>
    <span class="s">&quot;v&quot;</span><span class="o">:</span> <span class="s">&quot;1.0.0&quot;</span>
<span class="o">}</span>
</pre></div>
</div>
<p>第二次交互的接口返回：</p>
<table class="colwidths-given docutils align-default">
<colgroup>
<col style="width: 38%" />
<col style="width: 63%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>Key</p></th>
<th class="head"><p>Value</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>ErrorCode</p></td>
<td><p>错误码，0表示成功</p></td>
</tr>
<tr class="row-odd"><td><p>ErrorMessage</p></td>
<td><p>错误信息</p></td>
</tr>
<tr class="row-even"><td><p>respBody</p></td>
<td><p>WeIdentity DID</p></td>
</tr>
</tbody>
</table>
<p>返回示例：</p>
<div class="highlight-java notranslate"><div class="highlight"><pre><span></span><span class="o">{</span>
    <span class="s">&quot;ErrorCode&quot;</span><span class="o">:</span> <span class="mi">0</span><span class="o">,</span>
    <span class="s">&quot;ErrorMessage&quot;</span><span class="o">:</span> <span class="s">&quot;success&quot;</span><span class="o">,</span>
    <span class="s">&quot;respBody&quot;</span><span class="o">:</span> <span class="s">&quot;did:weid:0xfd28ad212a2de77fee518b4914b8579a40c601fa&quot;</span>
<span class="o">}</span>
</pre></div>
</div>
</div>
<div class="section" id="authority-issuer">
<h3>3. 注册Authority Issuer<a class="headerlink" href="#authority-issuer" title="永久链接至标题">¶</a></h3>
<p>第一次交互，POST /weid/api/encode 的接口入参：</p>
<table class="colwidths-given docutils align-default">
<colgroup>
<col style="width: 27%" />
<col style="width: 55%" />
<col style="width: 18%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>Key</p></th>
<th class="head"><p>Value</p></th>
<th class="head"><p>Required</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>functionName</p></td>
<td><p>registerAuthorityIssuer</p></td>
<td><p>Y</p></td>
</tr>
<tr class="row-odd"><td><p>functionArg</p></td>
<td></td>
<td><p>Y</p></td>
</tr>
<tr class="row-even"><td><p>functionArg.name</p></td>
<td><p>机构名</p></td>
<td><p>Y</p></td>
</tr>
<tr class="row-odd"><td><p>functionArg.weId</p></td>
<td><p>WeIdentity DID，与SDK直接调用的方式入参要求一致</p></td>
<td><p>Y</p></td>
</tr>
<tr class="row-even"><td><p>transactionArg</p></td>
<td></td>
<td><p>Y</p></td>
</tr>
<tr class="row-odd"><td><p>transactionArg.nonce</p></td>
<td><p>交易随机数</p></td>
<td><p>Y</p></td>
</tr>
<tr class="row-even"><td><p>v</p></td>
<td><p>版本号</p></td>
<td><p>Y</p></td>
</tr>
</tbody>
</table>
<p>第一次交互，POST /weid/api/encode 接口入参示例：</p>
<div class="highlight-java notranslate"><div class="highlight"><pre><span></span><span class="o">{</span>
    <span class="s">&quot;functionArg&quot;</span><span class="o">:</span> <span class="o">{</span>
        <span class="s">&quot;name&quot;</span><span class="o">:</span> <span class="s">&quot;BV-College&quot;</span><span class="o">,</span>
        <span class="s">&quot;weId&quot;</span><span class="o">:</span> <span class="s">&quot;did:weid:0xfd28ad212a2de77fee518b4914b8579a40c601fa&quot;</span>
    <span class="o">},</span>
    <span class="s">&quot;transactionArg&quot;</span><span class="o">:</span> <span class="o">{</span>
        <span class="s">&quot;nonce&quot;</span><span class="o">:</span> <span class="s">&quot;1474800601011307365506121304576347479508653499989424346408343855615822146039&quot;</span>
    <span class="o">},</span>
    <span class="s">&quot;functionName&quot;</span><span class="o">:</span> <span class="s">&quot;registerAuthorityIssuer&quot;</span><span class="o">,</span>
    <span class="s">&quot;v&quot;</span><span class="o">:</span> <span class="s">&quot;1.0.0&quot;</span>
<span class="o">}</span>
</pre></div>
</div>
<p>第二次交互，POST /weid/api/transact 接口入参示例：</p>
<div class="highlight-java notranslate"><div class="highlight"><pre><span></span><span class="o">{</span>
    <span class="s">&quot;functionArg&quot;</span><span class="o">:</span> <span class="o">{},</span>
    <span class="s">&quot;transactionArg&quot;</span><span class="o">:</span> <span class="o">{</span>
        <span class="s">&quot;nonce&quot;</span><span class="o">:</span> <span class="s">&quot;1474800601011307365506121304576347479508653499989424346408343855615822146039&quot;</span><span class="o">,</span>
        <span class="s">&quot;data&quot;</span><span class="o">:</span> <span class="s">&quot;809812638256c1235b1231000e000000001231287bacf213c&quot;</span><span class="o">,</span>
        <span class="s">&quot;signedMessage&quot;</span><span class="o">:</span> <span class="s">&quot;HEugP13uDVBg2G0kmmwbTkQXobsrWNqtGQJW6BoHU2Q2VQpwVhK382dArRMFN6BDq7ogozYBRC15QR8ueX5G3t8=&quot;</span>
    <span class="o">},</span>
    <span class="s">&quot;functionName&quot;</span><span class="o">:</span> <span class="s">&quot;registerAuthorityIssuer&quot;</span><span class="o">,</span>
    <span class="s">&quot;v&quot;</span><span class="o">:</span> <span class="s">&quot;1.0.0&quot;</span>
<span class="o">}</span>
</pre></div>
</div>
<p>第二次交互的接口返回：</p>
<table class="colwidths-given docutils align-default">
<colgroup>
<col style="width: 38%" />
<col style="width: 63%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>Key</p></th>
<th class="head"><p>Value</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>ErrorCode</p></td>
<td><p>错误码，0表示成功</p></td>
</tr>
<tr class="row-odd"><td><p>ErrorMessage</p></td>
<td><p>错误信息</p></td>
</tr>
<tr class="row-even"><td><p>respBody</p></td>
<td><p>Authority Isser信息</p></td>
</tr>
</tbody>
</table>
<p>返回示例：</p>
<div class="highlight-java notranslate"><div class="highlight"><pre><span></span><span class="o">{</span>
    <span class="s">&quot;ErrorCode&quot;</span><span class="o">:</span> <span class="mi">0</span><span class="o">,</span>
    <span class="s">&quot;ErrorMessage&quot;</span><span class="o">:</span> <span class="s">&quot;success&quot;</span><span class="o">,</span>
    <span class="s">&quot;respBody&quot;</span><span class="o">:</span> <span class="o">{</span>
        <span class="s">&quot;accValue&quot;</span><span class="o">:</span> <span class="o">,</span>
        <span class="s">&quot;created&quot;</span><span class="o">:</span> <span class="s">&quot;1581420650&quot;</span><span class="o">,</span>
        <span class="s">&quot;name&quot;</span><span class="o">:</span> <span class="s">&quot;BV-College&quot;</span><span class="o">,</span>
        <span class="s">&quot;weId&quot;</span><span class="o">:</span> <span class="s">&quot;did:weid:0xfd28ad212a2de77fee518b4914b8579a40c601fa&quot;</span>
    <span class="o">}</span>
<span class="o">}</span>
</pre></div>
</div>
</div>
<div class="section" id="id9">
<h3>4. 创建CPT<a class="headerlink" href="#id9" title="永久链接至标题">¶</a></h3>
<p>第一次交互，POST /weid/api/encode 的接口入参：</p>
<table class="colwidths-given docutils align-default">
<colgroup>
<col style="width: 27%" />
<col style="width: 55%" />
<col style="width: 18%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>Key</p></th>
<th class="head"><p>Value</p></th>
<th class="head"><p>Required</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>functionName</p></td>
<td><p>registerCpt</p></td>
<td><p>Y</p></td>
</tr>
<tr class="row-odd"><td><p>functionArg</p></td>
<td></td>
<td><p>Y</p></td>
</tr>
<tr class="row-even"><td><p>functionArg.cptJsonSchema</p></td>
<td><p>CPT Json Schema，与SDK直接调用的方式入参要求一致，下同</p></td>
<td><p>Y</p></td>
</tr>
<tr class="row-odd"><td><p>functionArg.weId</p></td>
<td><p>CPT创建者</p></td>
<td><p>Y</p></td>
</tr>
<tr class="row-even"><td><p>functionArg.cptSignature</p></td>
<td><p>创建者使用自己的私钥对cptJsonSchema的签名（和私钥托管方式不同，本方式特有）</p></td>
<td><p>Y</p></td>
</tr>
<tr class="row-odd"><td><p>transactionArg</p></td>
<td></td>
<td><p>Y</p></td>
</tr>
<tr class="row-even"><td><p>transactionArg.nonce</p></td>
<td><p>交易随机数</p></td>
<td><p>Y</p></td>
</tr>
<tr class="row-odd"><td><p>v</p></td>
<td><p>版本号</p></td>
<td><p>Y</p></td>
</tr>
</tbody>
</table>
<p>第一次交互，POST /weid/api/encode 接口入参示例：</p>
<div class="highlight-java notranslate"><div class="highlight"><pre><span></span><span class="o">{</span>
    <span class="s">&quot;functionArg&quot;</span><span class="o">:</span> <span class="o">{</span>
        <span class="s">&quot;weId&quot;</span><span class="o">:</span> <span class="s">&quot;did:weid:0x1ae5b88d37327830307ab8da0ec5d8e8692a35d3&quot;</span><span class="o">,</span>
        <span class="s">&quot;cptJsonSchema&quot;</span><span class="o">:</span> <span class="o">{</span>
            <span class="s">&quot;title&quot;</span><span class="o">:</span> <span class="s">&quot;cpt&quot;</span><span class="o">,</span>
            <span class="s">&quot;description&quot;</span><span class="o">:</span> <span class="s">&quot;this is cpt&quot;</span><span class="o">,</span>
            <span class="s">&quot;properties&quot;</span><span class="o">:</span> <span class="o">{</span>
                <span class="s">&quot;name&quot;</span><span class="o">:</span> <span class="o">{</span>
                    <span class="s">&quot;type&quot;</span><span class="o">:</span> <span class="s">&quot;string&quot;</span><span class="o">,</span>
                    <span class="s">&quot;description&quot;</span><span class="o">:</span> <span class="s">&quot;the name of certificate owner&quot;</span>
                <span class="o">},</span>
                <span class="s">&quot;gender&quot;</span><span class="o">:</span> <span class="o">{</span>
                    <span class="s">&quot;enum&quot;</span><span class="o">:</span> <span class="o">[</span>
                        <span class="s">&quot;F&quot;</span><span class="o">,</span>
                        <span class="s">&quot;M&quot;</span>
                    <span class="o">],</span>
                    <span class="s">&quot;type&quot;</span><span class="o">:</span> <span class="s">&quot;string&quot;</span><span class="o">,</span>
                    <span class="s">&quot;description&quot;</span><span class="o">:</span> <span class="s">&quot;the gender of certificate owner&quot;</span>
                <span class="o">},</span>
                <span class="s">&quot;age&quot;</span><span class="o">:</span> <span class="o">{</span>
                    <span class="s">&quot;type&quot;</span><span class="o">:</span> <span class="s">&quot;number&quot;</span><span class="o">,</span>
                    <span class="s">&quot;description&quot;</span><span class="o">:</span> <span class="s">&quot;the age of certificate owner&quot;</span>
                <span class="o">}</span>
            <span class="o">},</span>
            <span class="s">&quot;required&quot;</span><span class="o">:</span> <span class="o">[</span>
                <span class="s">&quot;name&quot;</span><span class="o">,</span>
                <span class="s">&quot;age&quot;</span>
            <span class="o">]</span>
        <span class="o">}</span>
        <span class="s">&quot;cptSignature&quot;</span><span class="o">:</span> <span class="s">&quot;BaUeP13uDVBg2G0kmmwbTkQXobsrWNqtGQJW6BoHU2Q2VQpwVhK382dArRMFN6BDq7ogozYBRC15QR8ueX5G3t8=&quot;</span>
    <span class="o">},</span>
    <span class="s">&quot;transactionArg&quot;</span><span class="o">:</span> <span class="o">{</span>
        <span class="s">&quot;nonce&quot;</span><span class="o">:</span> <span class="s">&quot;1474800601011307365506121304576347479508653499989424346408343855615822146039&quot;</span>
    <span class="o">},</span>
    <span class="s">&quot;functionName&quot;</span><span class="o">:</span> <span class="s">&quot;registerCpt&quot;</span><span class="o">,</span>
    <span class="s">&quot;v&quot;</span><span class="o">:</span> <span class="s">&quot;1.0.0&quot;</span>
<span class="o">}</span>
</pre></div>
</div>
<p>第二次交互，POST /weid/api/transact 接口入参示例：</p>
<div class="highlight-java notranslate"><div class="highlight"><pre><span></span><span class="o">{</span>
    <span class="s">&quot;functionArg&quot;</span><span class="o">:</span> <span class="o">{},</span>
    <span class="s">&quot;transactionArg&quot;</span><span class="o">:</span> <span class="o">{</span>
        <span class="s">&quot;nonce&quot;</span><span class="o">:</span> <span class="s">&quot;1474800601011307365506121304576347479508653499989424346408343855615822146039&quot;</span><span class="o">,</span>
        <span class="s">&quot;data&quot;</span><span class="o">:</span> <span class="s">&quot;809812638256c1235b1231000e000000001231287bacf213c&quot;</span><span class="o">,</span>
        <span class="s">&quot;signedMessage&quot;</span><span class="o">:</span> <span class="s">&quot;HEugP13uDVBg2G0kmmwbTkQXobsrWNqtGQJW6BoHU2Q2VQpwVhK382dArRMFN6BDq7ogozYBRC15QR8ueX5G3t8=&quot;</span>
    <span class="o">},</span>
    <span class="s">&quot;functionName&quot;</span><span class="o">:</span> <span class="s">&quot;registerAuthorityIssuer&quot;</span><span class="o">,</span>
    <span class="s">&quot;v&quot;</span><span class="o">:</span> <span class="s">&quot;1.0.0&quot;</span>
<span class="o">}</span>
</pre></div>
</div>
<p>第二次交互的接口返回：</p>
<table class="colwidths-given docutils align-default">
<colgroup>
<col style="width: 38%" />
<col style="width: 63%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>Key</p></th>
<th class="head"><p>Value</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>ErrorCode</p></td>
<td><p>错误码，0表示成功</p></td>
</tr>
<tr class="row-odd"><td><p>ErrorMessage</p></td>
<td><p>错误信息</p></td>
</tr>
<tr class="row-even"><td><p>respBody</p></td>
<td><p>Authority Isser信息</p></td>
</tr>
</tbody>
</table>
<p>返回示例：</p>
<div class="highlight-java notranslate"><div class="highlight"><pre><span></span><span class="o">{</span>
    <span class="s">&quot;ErrorCode&quot;</span><span class="o">:</span> <span class="mi">0</span><span class="o">,</span>
    <span class="s">&quot;ErrorMessage&quot;</span><span class="o">:</span> <span class="s">&quot;success&quot;</span><span class="o">,</span>
    <span class="s">&quot;respBody&quot;</span><span class="o">:</span> <span class="o">{</span>
        <span class="s">&quot;cptId&quot;</span><span class="o">:</span> <span class="mi">2000001</span><span class="o">,</span>
        <span class="s">&quot;cptVersion&quot;</span><span class="o">:</span> <span class="mi">1</span>
    <span class="o">}</span>
<span class="o">}</span>
</pre></div>
</div>
</div>
<div class="section" id="id10">
<h3>5. 创建CredentialPojo<a class="headerlink" href="#id10" title="永久链接至标题">¶</a></h3>
<p>创建CredentialPojo不需要进行区块链交互，因此，只需要进行一次交互POST /weid/api/encode，然后对返回的结果进行签名即可：</p>
<p>POST /weid/api/encode 接口入参</p>
<table class="colwidths-given docutils align-default">
<colgroup>
<col style="width: 27%" />
<col style="width: 55%" />
<col style="width: 18%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>Key</p></th>
<th class="head"><p>Value</p></th>
<th class="head"><p>Required</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>functionName</p></td>
<td><p>createCredentialPojo</p></td>
<td><p>Y</p></td>
</tr>
<tr class="row-odd"><td><p>functionArg</p></td>
<td></td>
<td><p>Y</p></td>
</tr>
<tr class="row-even"><td><p>functionArg.claim</p></td>
<td><p>claim Json结构体，与SDK直接调用的方式入参一致，下同</p></td>
<td><p>Y</p></td>
</tr>
<tr class="row-odd"><td><p>functionArg.cptId</p></td>
<td><p>CPT ID</p></td>
<td><p>Y</p></td>
</tr>
<tr class="row-even"><td><p>functionArg.issuer</p></td>
<td><p>issuer WeIdentity DID</p></td>
<td><p>Y</p></td>
</tr>
<tr class="row-odd"><td><p>functionArg.expirationDate</p></td>
<td><p>过期时间（使用UTC格式）</p></td>
<td><p>Y</p></td>
</tr>
<tr class="row-even"><td><p>transactionArg</p></td>
<td><p>为空</p></td>
<td><p>Y</p></td>
</tr>
<tr class="row-odd"><td><p>v</p></td>
<td><p>版本号</p></td>
<td><p>Y</p></td>
</tr>
</tbody>
</table>
<p>接口入参：Json，以signature代替私钥</p>
<div class="highlight-java notranslate"><div class="highlight"><pre><span></span><span class="o">{</span>
    <span class="s">&quot;functionArg&quot;</span><span class="o">:</span> <span class="o">{</span>
        <span class="s">&quot;cptId&quot;</span><span class="o">:</span> <span class="mi">10</span><span class="o">,</span>
        <span class="s">&quot;issuer&quot;</span><span class="o">:</span> <span class="s">&quot;did:weid:0xfd28ad212a2de77fee518b4914b8579a40c601fa&quot;</span><span class="o">,</span>
        <span class="s">&quot;expirationDate&quot;</span><span class="o">:</span> <span class="s">&quot;2019-04-18T21:12:33Z&quot;</span><span class="o">,</span>
        <span class="s">&quot;claim&quot;</span><span class="o">:</span> <span class="o">{</span>
            <span class="s">&quot;name&quot;</span><span class="o">:</span> <span class="s">&quot;zhang san&quot;</span><span class="o">,</span>
            <span class="s">&quot;gender&quot;</span><span class="o">:</span> <span class="s">&quot;F&quot;</span><span class="o">,</span>
            <span class="s">&quot;age&quot;</span><span class="o">:</span> <span class="mi">18</span>
        <span class="o">},</span>
    <span class="o">},</span>
    <span class="s">&quot;transactionArg&quot;</span><span class="o">:</span> <span class="o">{</span>
    <span class="o">},</span>
    <span class="s">&quot;functionName&quot;</span><span class="o">:</span> <span class="s">&quot;createCredentialPojo&quot;</span><span class="o">,</span>
    <span class="s">&quot;v&quot;</span><span class="o">:</span> <span class="s">&quot;1.0.0&quot;</span>
<span class="o">}</span>
</pre></div>
</div>
<p>接口返回: application/json</p>
<table class="colwidths-given docutils align-default">
<colgroup>
<col style="width: 38%" />
<col style="width: 63%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>Key</p></th>
<th class="head"><p>Value</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>ErrorCode</p></td>
<td><p>错误码，0表示成功</p></td>
</tr>
<tr class="row-odd"><td><p>ErrorMessage</p></td>
<td><p>错误信息</p></td>
</tr>
<tr class="row-even"><td><p>respBody</p></td>
<td><p>完整的CredentialPojo信息</p></td>
</tr>
</tbody>
</table>
<p>接口返回示例:</p>
<div class="highlight-java notranslate"><div class="highlight"><pre><span></span><span class="o">{</span>
  <span class="s">&quot;respBody&quot;</span><span class="o">:</span> <span class="o">{</span>
      <span class="s">&quot;cptId&quot;</span><span class="o">:</span> <span class="mi">2000156</span><span class="o">,</span>
      <span class="s">&quot;issuanceDate&quot;</span><span class="o">:</span> <span class="mi">1580996777</span><span class="o">,</span>
      <span class="s">&quot;context&quot;</span><span class="o">:</span> <span class="s">&quot;https://github.com/WeBankBlockchain/WeIdentity/blob/master/context/v1&quot;</span><span class="o">,</span>
      <span class="s">&quot;claim&quot;</span><span class="o">:</span> <span class="o">{</span>
          <span class="s">&quot;content&quot;</span><span class="o">:</span> <span class="s">&quot;b1016358-cf72-42be-9f4b-a18fca610fca&quot;</span><span class="o">,</span>
          <span class="s">&quot;receiver&quot;</span><span class="o">:</span> <span class="s">&quot;did:weid:101:0x7ed16eca3b0737227bc986dd0f2851f644cf4754&quot;</span><span class="o">,</span>
          <span class="s">&quot;weid&quot;</span><span class="o">:</span> <span class="s">&quot;did:weid:101:0xfd28ad212a2de77fee518b4914b8579a40c601fa&quot;</span>
      <span class="o">},</span>
      <span class="s">&quot;id&quot;</span><span class="o">:</span> <span class="s">&quot;21d10ab1-75fe-4733-9f1d-f0bad71b5922&quot;</span><span class="o">,</span>
      <span class="s">&quot;proof&quot;</span><span class="o">:</span> <span class="o">{</span>
          <span class="s">&quot;created&quot;</span><span class="o">:</span> <span class="mi">1580996777</span><span class="o">,</span>
          <span class="s">&quot;creator&quot;</span><span class="o">:</span> <span class="s">&quot;did:weid:101:0xfd28ad212a2de77fee518b4914b8579a40c601fa#keys-0&quot;</span><span class="o">,</span>
          <span class="s">&quot;salt&quot;</span><span class="o">:</span> <span class="o">{</span>
              <span class="s">&quot;content&quot;</span><span class="o">:</span> <span class="s">&quot;ncZ5F&quot;</span><span class="o">,</span>
              <span class="s">&quot;receiver&quot;</span><span class="o">:</span> <span class="s">&quot;L0c40&quot;</span><span class="o">,</span>
              <span class="s">&quot;weid&quot;</span><span class="o">:</span> <span class="s">&quot;I4aop&quot;</span>
          <span class="o">},</span>
          <span class="s">&quot;signatureValue&quot;</span><span class="o">:</span> <span class="s">&quot;HJPbDmoi39xgZBGi/aj1zB6VQL5QLyt4qTV6GOvQwzfgUJEZTazKZXe1dRg5aCt8Q44GwNF2k+l1rfhpY1hc/ls=&quot;</span><span class="o">,</span>
          <span class="s">&quot;type&quot;</span><span class="o">:</span> <span class="s">&quot;Secp256k1&quot;</span>
      <span class="o">},</span>
      <span class="s">&quot;type&quot;</span><span class="o">:</span> <span class="o">[</span>
          <span class="s">&quot;VerifiableCredential&quot;</span><span class="o">,</span>
          <span class="s">&quot;hashTree&quot;</span>
      <span class="o">],</span>
      <span class="s">&quot;issuer&quot;</span><span class="o">:</span> <span class="s">&quot;did:weid:101:0xfd28ad212a2de77fee518b4914b8579a40c601fa&quot;</span><span class="o">,</span>
      <span class="s">&quot;expirationDate&quot;</span><span class="o">:</span> <span class="mi">4111737153</span>
  <span class="o">},</span>
  <span class="s">&quot;errorCode&quot;</span><span class="o">:</span> <span class="mi">0</span><span class="o">,</span>
  <span class="s">&quot;errorMessage&quot;</span><span class="o">:</span> <span class="s">&quot;success&quot;</span>
<span class="o">}</span>
</pre></div>
</div>
<p>请注意，这个生成的CredentialPojo的签名值（proof中的signatureValue项）并没有经过私钥签名。因此，您还需要其经过Base64解码之后，再使用Issuer的私钥进行签名并Base64编码，就能得到一个正确的CredentialPojo了。</p>
<p>使用ECDSA私钥进行签名和Base64编码的范例代码见下：</p>
<div class="highlight-java notranslate"><div class="highlight"><pre><span></span><span class="n">String</span> <span class="n">signature</span> <span class="o">=</span> <span class="n">DataToolUtils</span><span class="o">.</span><span class="na">sign</span><span class="o">(</span><span class="k">new</span> <span class="n">String</span><span class="o">(</span><span class="n">DataToolUtils</span><span class="o">.</span><span class="na">base64Decode</span><span class="o">(</span><span class="n">signatureValue</span><span class="o">)),</span> <span class="n">privateKey</span><span class="o">);</span>
</pre></div>
</div>
</div>
</div>
<div class="section" id="weidentity-endpoint-service-api">
<h2>WeIdentity Endpoint Service API<a class="headerlink" href="#weidentity-endpoint-service-api" title="永久链接至标题">¶</a></h2>
<div class="section" id="endpoint">
<h3>1. 获取所有已注册的Endpoint信息<a class="headerlink" href="#endpoint" title="永久链接至标题">¶</a></h3>
<p>调用接口：</p>
<table class="colwidths-given docutils align-default">
<colgroup>
<col style="width: 38%" />
<col style="width: 63%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>标题</p></th>
<th class="head"><p>描述</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>接口名</p></td>
<td><p>weid/api/endpoint</p></td>
</tr>
<tr class="row-odd"><td><p>Method</p></td>
<td><p>GET</p></td>
</tr>
<tr class="row-even"><td><p>Content-Type</p></td>
<td><p>application/json</p></td>
</tr>
</tbody>
</table>
<p>接口入参：无</p>
<p>接口返回：</p>
<div class="highlight-java notranslate"><div class="highlight"><pre><span></span><span class="o">{</span>
    <span class="s">&quot;ErrorCode&quot;</span><span class="o">:</span> <span class="mi">0</span><span class="o">,</span>
    <span class="s">&quot;ErrorMessage&quot;</span><span class="o">:</span> <span class="s">&quot;success&quot;</span><span class="o">,</span>
    <span class="s">&quot;respBody&quot;</span><span class="o">:</span> <span class="o">[</span>
        <span class="o">{</span>
            <span class="s">&quot;requestName&quot;</span><span class="o">:</span> <span class="s">&quot;create-passphrase&quot;</span><span class="o">,</span>
            <span class="s">&quot;inAddr&quot;</span><span class="o">:</span> <span class="o">[</span>
                <span class="s">&quot;127.0.0.1:6010&quot;</span><span class="o">,</span>
                <span class="s">&quot;127.0.0.1:6011&quot;</span>
            <span class="o">],</span>
            <span class="s">&quot;description&quot;</span><span class="o">:</span> <span class="s">&quot;Create a valid random passphrase&quot;</span>
        <span class="o">},</span>
        <span class="o">{</span>
            <span class="s">&quot;requestName&quot;</span><span class="o">:</span> <span class="s">&quot;verify-passphrase&quot;</span><span class="o">,</span>
            <span class="s">&quot;inAddr&quot;</span><span class="o">:</span> <span class="o">[</span>
                <span class="s">&quot;127.0.0.1:6012&quot;</span><span class="o">,</span>
                <span class="s">&quot;127.0.0.1:6013&quot;</span>
            <span class="o">],</span>
            <span class="s">&quot;description&quot;</span><span class="o">:</span> <span class="s">&quot;Verify a passphrase&quot;</span>
        <span class="o">}</span>
    <span class="o">]</span>
<span class="o">}</span>
</pre></div>
</div>
</div>
<div class="section" id="id11">
<h3>2. 进行Endpoint调用<a class="headerlink" href="#id11" title="永久链接至标题">¶</a></h3>
<p>调用接口：</p>
<table class="colwidths-given docutils align-default">
<colgroup>
<col style="width: 38%" />
<col style="width: 63%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>标题</p></th>
<th class="head"><p>描述</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>接口名</p></td>
<td><p>weid/api/endpoint/{endpoint}</p></td>
</tr>
<tr class="row-odd"><td><p>Method</p></td>
<td><p>POST</p></td>
</tr>
<tr class="row-even"><td><p>Content-Type</p></td>
<td><p>application/json</p></td>
</tr>
</tbody>
</table>
<p>接口入参：</p>
<table class="colwidths-given docutils align-default">
<colgroup>
<col style="width: 27%" />
<col style="width: 55%" />
<col style="width: 18%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>Key</p></th>
<th class="head"><p>Value</p></th>
<th class="head"><p>Required</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>/{endpoint}</p></td>
<td><p>在API路径中标明的API名，String</p></td>
<td><p>Y</p></td>
</tr>
<tr class="row-odd"><td><p>body</p></td>
<td><p>以```分隔的多个传入服务端用于执行API的参数</p></td>
<td><p>Y</p></td>
</tr>
</tbody>
</table>
<p>接口入参：</p>
<div class="highlight-java notranslate"><div class="highlight"><pre><span></span><span class="o">{</span>
    <span class="s">&quot;body&quot;</span><span class="o">:</span> <span class="s">&quot;did:weid:0xfd28ad212a2de77fee518b4914b8579a40c601fa```25&quot;</span>
<span class="o">}</span>
</pre></div>
</div>
<p>接口返回: application/json</p>
<table class="colwidths-given docutils align-default">
<colgroup>
<col style="width: 38%" />
<col style="width: 63%" />
</colgroup>
<thead>
<tr class="row-odd"><th class="head"><p>Key</p></th>
<th class="head"><p>Value</p></th>
</tr>
</thead>
<tbody>
<tr class="row-even"><td><p>ErrorCode</p></td>
<td><p>错误码，0表示成功</p></td>
</tr>
<tr class="row-odd"><td><p>ErrorMessage</p></td>
<td><p>错误信息</p></td>
</tr>
<tr class="row-even"><td><p>respBody</p></td>
<td><p>SDK侧的返回值，String</p></td>
</tr>
</tbody>
</table>
<p>接口返回：</p>
<div class="highlight-java notranslate"><div class="highlight"><pre><span></span><span class="o">{</span>
    <span class="s">&quot;ErrorCode&quot;</span><span class="o">:</span> <span class="mi">0</span><span class="o">,</span>
    <span class="s">&quot;ErrorMessage&quot;</span><span class="o">:</span> <span class="s">&quot;success&quot;</span><span class="o">,</span>
    <span class="s">&quot;respBody&quot;</span><span class="o">:</span> <span class="s">&quot;did:weid:0x1Ae5b88d37327830307ab8da0ec5D8E8692A35D3&quot;</span><span class="o">,</span>
<span class="o">}</span>
</pre></div>
</div>
</div>
</div>
</div>


           </div>
           
          </div>
          <footer>
  
    <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
      
        <a href="weidentity-rest-design.html" class="btn btn-neutral float-right" title="WeIdentity RestService 设计文档" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right"></span></a>
      
      
        <a href="weidentity-rest-deploy.html" class="btn btn-neutral" title="WeIdentity RestService 部署文档" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left"></span> Previous</a>
      
    </div>
  

  <hr/>

  <div role="contentinfo">
    <p>
        &copy; Copyright (2018) WeBank Co., Ltd.

    </p>
  </div>
  Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/rtfd/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>. 

</footer>

        </div>
      </div>

    </section>

  </div>
  


  

    
    
      <script type="text/javascript" id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></script>
        <script src="../_static/jquery.js"></script>
        <script src="../_static/underscore.js"></script>
        <script src="../_static/doctools.js"></script>
        <script src="../_static/language_data.js"></script>
        <script src="../_static/translations.js"></script>
    

  

  <script type="text/javascript" src="../_static/js/theme.js"></script>

  <script type="text/javascript">
      jQuery(function () {
          SphinxRtdTheme.Navigation.enable(true);
      });
  </script> 

</body>
</html>